mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,675 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.corelib.Utils;
|
||||
import com.sbi.corelib.audio.SBAudio;
|
||||
import flash.net.SharedObject;
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class AJAudio
|
||||
{
|
||||
|
||||
private static var _hasLoadedDailySpinSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedGiftUnwrapSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedJourneyBookWorldSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedJourneyBookBookSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedTradeSfx:Boolean;
|
||||
|
||||
private static var _hasLoadedPetCreateSfx:Boolean;
|
||||
|
||||
private static var _defaultVolumes:Dictionary;
|
||||
|
||||
public function AJAudio()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(param1:Function = null, param2:Object = null) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
if(!SBAudio.isInitialized)
|
||||
{
|
||||
_loc3_ = {};
|
||||
_loc3_["HudBtnRollover"] = {
|
||||
"className":Utils.getDefByName("HudBtnRollover") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["HudBtnClick"] = {
|
||||
"className":Utils.getDefByName("HudBtnClick") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["SubMenuBtnRollover"] = {
|
||||
"className":Utils.getDefByName("SubMenuBtnRollover") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["SubMenuBtnClick"] = {
|
||||
"className":Utils.getDefByName("SubMenuBtnClick") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["ExitBtnRollover"] = {
|
||||
"className":Utils.getDefByName("ExitBtnRollover") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["ExitBtnClick"] = {
|
||||
"className":Utils.getDefByName("ExitBtnClick") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["ScrollUpDown"] = {
|
||||
"className":Utils.getDefByName("ScrollUpDown") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["ScrollLeftRight"] = {
|
||||
"className":Utils.getDefByName("ScrollLeftRight") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["TextType"] = {
|
||||
"className":Utils.getDefByName("TextType") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["TextEnter"] = {
|
||||
"className":Utils.getDefByName("TextEnter") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["IdleWarningSound"] = {
|
||||
"className":Utils.getDefByName("IdleWarningSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["ShopCachingSound"] = {
|
||||
"className":Utils.getDefByName("ShopCachingSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["GemsEarnedSound"] = {
|
||||
"className":Utils.getDefByName("GemsEarnedSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["ItemRecycledSound"] = {
|
||||
"className":Utils.getDefByName("ItemRecycledSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["MailReceivedSound"] = {
|
||||
"className":Utils.getDefByName("MailReceivedSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["BuddyOnlineOfflineSound"] = {
|
||||
"className":Utils.getDefByName("BuddyOnlineOfflineSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["NewspaperSound"] = {
|
||||
"className":Utils.getDefByName("NewspaperSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["MailSentSound"] = {
|
||||
"className":Utils.getDefByName("MailSentSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["AchievementSound"] = {
|
||||
"className":Utils.getDefByName("AchievementSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["BuddyCardOpen"] = {
|
||||
"className":Utils.getDefByName("BuddyCardOpen") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["BuddyCardClose"] = {
|
||||
"className":Utils.getDefByName("BuddyCardClose") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["LimitedChatErrorSound"] = {
|
||||
"className":Utils.getDefByName("LimitedChatErrorSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["ChatOpenSound"] = {
|
||||
"className":Utils.getDefByName("ChatOpenSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["ChatCloseSound"] = {
|
||||
"className":Utils.getDefByName("ChatCloseSound") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["RandomLever"] = {
|
||||
"className":Utils.getDefByName("RandomLever") as Class,
|
||||
"volume":0.2
|
||||
};
|
||||
_loc3_["NameGenRotationSound"] = {
|
||||
"className":Utils.getDefByName("NameGenRotationSound") as Class,
|
||||
"volume":1
|
||||
};
|
||||
_loc3_["NameGenStopSound"] = {
|
||||
"className":Utils.getDefByName("NameGenStopSound") as Class,
|
||||
"volume":1
|
||||
};
|
||||
_loc3_["DoorBellSound"] = {
|
||||
"className":Utils.getDefByName("DoorBellSound") as Class,
|
||||
"volume":1
|
||||
};
|
||||
SBAudio.init(_loc3_,param1,param2);
|
||||
_defaultVolumes = new Dictionary();
|
||||
_defaultVolumes["FW_TRAIL_1"] = 0.2;
|
||||
_defaultVolumes["FW_TRAIL_2"] = 0.2;
|
||||
_defaultVolumes["FW_TRAIL_3"] = 0.2;
|
||||
_defaultVolumes["FW_LAUNCH_1"] = 0.3;
|
||||
_defaultVolumes["FW_LAUNCH_2"] = 0.3;
|
||||
_defaultVolumes["FW_LAUNCH_3"] = 0.3;
|
||||
_defaultVolumes["FW_EXPLOSION_1"] = 0.3;
|
||||
_defaultVolumes["FW_EXPLOSION_2"] = 0.3;
|
||||
_defaultVolumes["FW_EXPLOSION_3"] = 0.3;
|
||||
_defaultVolumes["DOOR_WOOD_OPEN"] = 0.3;
|
||||
_defaultVolumes["DOOR_WOOD_CLOSE"] = 0.3;
|
||||
_defaultVolumes["DOOR_SLIDE"] = 0.3;
|
||||
_defaultVolumes["DOOR_STONE_SLIDE"] = 0.3;
|
||||
_defaultVolumes["aj_water_fs1"] = 0;
|
||||
_defaultVolumes["aj_water_fs2"] = 0;
|
||||
_defaultVolumes["aj_water_fs3"] = 0;
|
||||
_defaultVolumes["BOUNCE"] = 0.4;
|
||||
_defaultVolumes["aj_slideBounce1"] = 0.28;
|
||||
_defaultVolumes["aj_slideBounce2"] = 0.28;
|
||||
_defaultVolumes["aj_JBCameraHide"] = 0.3;
|
||||
_defaultVolumes["aj_JBCameraReveal"] = 0.3;
|
||||
_defaultVolumes["aj_JBcarrotBounce"] = 0.3;
|
||||
_defaultVolumes["aj_JBcarrotsPop"] = 0.3;
|
||||
_defaultVolumes["aj_JBcarrotsRing"] = 0.3;
|
||||
_defaultVolumes["aj_JBcosmoHatAppear"] = 0.3;
|
||||
_defaultVolumes["aj_JBcosmoHatBoomSeedAppear"] = 0.3;
|
||||
_defaultVolumes["aj_JBcosmoHatBoomSeedFall"] = 0.3;
|
||||
_defaultVolumes["aj_JBcosmoHatFall"] = 0.3;
|
||||
_defaultVolumes["aj_JBgilbertArmorClose"] = 0.3;
|
||||
_defaultVolumes["aj_JBgilbertArmorOpen"] = 0.3;
|
||||
_defaultVolumes["aj_JBgrahamGearLP"] = 0.3;
|
||||
_defaultVolumes["aj_JBgreelyCapeEnter"] = 0.3;
|
||||
_defaultVolumes["aj_JBgreelyCapeExit"] = 0.3;
|
||||
_defaultVolumes["aj_JBlizaCompassHide"] = 0.3;
|
||||
_defaultVolumes["aj_JBlizaCompassReveal"] = 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
public static function loadSfx(param1:String, param2:Class, param3:Number = 0.3) : void
|
||||
{
|
||||
if(_defaultVolumes[param1])
|
||||
{
|
||||
param3 = Number(_defaultVolumes[param1]);
|
||||
}
|
||||
SBAudio.addCachedSound(param1,param2,param3);
|
||||
}
|
||||
|
||||
public static function setupSharedObject(param1:SharedObject) : void
|
||||
{
|
||||
SBAudio.setupSharedObject(param1);
|
||||
}
|
||||
|
||||
public static function playSfx(param1:String, param2:int = 1) : void
|
||||
{
|
||||
SBAudio.playCachedSound(param1,param2);
|
||||
}
|
||||
|
||||
public static function stopSfx(param1:String) : void
|
||||
{
|
||||
SBAudio.stopCachedSound(param1);
|
||||
}
|
||||
|
||||
public static function playHudBtnRollover() : void
|
||||
{
|
||||
playSfx("HudBtnRollover");
|
||||
}
|
||||
|
||||
public static function playHudBtnClick() : void
|
||||
{
|
||||
playSfx("HudBtnClick");
|
||||
}
|
||||
|
||||
public static function playSubMenuBtnRollover() : void
|
||||
{
|
||||
playSfx("SubMenuBtnRollover");
|
||||
}
|
||||
|
||||
public static function playSubMenuBtnClick() : void
|
||||
{
|
||||
playSfx("SubMenuBtnClick");
|
||||
}
|
||||
|
||||
public static function playExitBtnRollover() : void
|
||||
{
|
||||
playSfx("ExitBtnRollover");
|
||||
}
|
||||
|
||||
public static function playExitBtnClick() : void
|
||||
{
|
||||
playSfx("ExitBtnClick");
|
||||
}
|
||||
|
||||
public static function playScrollUpDown() : void
|
||||
{
|
||||
playSfx("ScrollUpDown");
|
||||
}
|
||||
|
||||
public static function playScrollLeftRight() : void
|
||||
{
|
||||
playSfx("ScrollLeftRight");
|
||||
}
|
||||
|
||||
public static function playTextType() : void
|
||||
{
|
||||
playSfx("TextType");
|
||||
}
|
||||
|
||||
public static function playTextEnter() : void
|
||||
{
|
||||
playSfx("TextEnter");
|
||||
}
|
||||
|
||||
public static function playIdleWarningSound() : void
|
||||
{
|
||||
playSfx("IdleWarningSound");
|
||||
}
|
||||
|
||||
public static function playShopCachingSound() : void
|
||||
{
|
||||
playSfx("ShopCachingSound");
|
||||
}
|
||||
|
||||
public static function playGemsEarnedSound() : void
|
||||
{
|
||||
playSfx("GemsEarnedSound");
|
||||
}
|
||||
|
||||
public static function playItemRecycledSound() : void
|
||||
{
|
||||
playSfx("ItemRecycledSound");
|
||||
}
|
||||
|
||||
public static function playMailReceivedSound() : void
|
||||
{
|
||||
playSfx("MailReceivedSound");
|
||||
}
|
||||
|
||||
public static function playMailSentSound() : void
|
||||
{
|
||||
playSfx("MailSentSound");
|
||||
}
|
||||
|
||||
public static function playBuddyOnlineOfflineSound() : void
|
||||
{
|
||||
playSfx("BuddyOnlineOfflineSound");
|
||||
}
|
||||
|
||||
public static function playNewspaperSound() : void
|
||||
{
|
||||
playSfx("NewspaperSound");
|
||||
}
|
||||
|
||||
public static function playAchievementSound() : void
|
||||
{
|
||||
playSfx("AchievementSound");
|
||||
}
|
||||
|
||||
public static function playBuddyCardOpen() : void
|
||||
{
|
||||
playSfx("BuddyCardOpen");
|
||||
}
|
||||
|
||||
public static function playBuddyCardClose() : void
|
||||
{
|
||||
playSfx("BuddyCardClose");
|
||||
}
|
||||
|
||||
public static function playLimitedChatErrorSound() : void
|
||||
{
|
||||
playSfx("LimitedChatErrorSound");
|
||||
}
|
||||
|
||||
public static function playChatOpenSound() : void
|
||||
{
|
||||
playSfx("ChatOpenSound");
|
||||
}
|
||||
|
||||
public static function playChatCloseSound() : void
|
||||
{
|
||||
playSfx("ChatCloseSound");
|
||||
}
|
||||
|
||||
public static function playRandomLever() : void
|
||||
{
|
||||
playSfx("RandomLever");
|
||||
}
|
||||
|
||||
public static function playNameGenRotationSound(param1:int = 1) : void
|
||||
{
|
||||
playSfx("NameGenRotationSound",param1);
|
||||
}
|
||||
|
||||
public static function playNameGenStopSound() : void
|
||||
{
|
||||
playSfx("NameGenStopSound");
|
||||
}
|
||||
|
||||
public static function playDoorBellSound() : void
|
||||
{
|
||||
playSfx("DoorBellSound");
|
||||
}
|
||||
|
||||
public static function stopNameGenRotationSound() : void
|
||||
{
|
||||
stopSfx("NameGenRotationSound");
|
||||
}
|
||||
|
||||
public static function stopRandomLever() : void
|
||||
{
|
||||
stopSfx("RandomLever");
|
||||
}
|
||||
|
||||
public static function get hasLoadedDailySpinSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedDailySpinSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedDailySpinSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedDailySpinSfx = param1;
|
||||
}
|
||||
|
||||
public static function playDailySpinSpin() : void
|
||||
{
|
||||
if(!_hasLoadedDailySpinSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("DailySpinSpin");
|
||||
}
|
||||
|
||||
public static function playDailySpinBub1() : void
|
||||
{
|
||||
if(!_hasLoadedDailySpinSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("DailySpinBub1");
|
||||
}
|
||||
|
||||
public static function playDailySpinBub2() : void
|
||||
{
|
||||
if(!_hasLoadedDailySpinSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("DailySpinBub2");
|
||||
}
|
||||
|
||||
public static function playDailySpinBub3() : void
|
||||
{
|
||||
if(!_hasLoadedDailySpinSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("DailySpinBub3");
|
||||
}
|
||||
|
||||
public static function get hasLoadedGiftUnwrapSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedGiftUnwrapSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedGiftUnwrapSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedGiftUnwrapSfx = param1;
|
||||
}
|
||||
|
||||
public static function playGiftUnwrap() : void
|
||||
{
|
||||
if(!_hasLoadedGiftUnwrapSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("GiftUnwrap");
|
||||
}
|
||||
|
||||
public static function playTreasureUnwrap() : void
|
||||
{
|
||||
if(!_hasLoadedGiftUnwrapSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TreasureUnwrap");
|
||||
}
|
||||
|
||||
public static function playTreasureBagUnwrap() : void
|
||||
{
|
||||
if(!_hasLoadedGiftUnwrapSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TreasureBagUnwrap");
|
||||
}
|
||||
|
||||
public static function playTreasureLuckyUnwrap() : void
|
||||
{
|
||||
if(!_hasLoadedGiftUnwrapSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("EpicLuckyTreasureUnwrap");
|
||||
}
|
||||
|
||||
public static function playTreasureLucky2Unwrap() : void
|
||||
{
|
||||
if(!_hasLoadedGiftUnwrapSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("potOgoldPopUp");
|
||||
}
|
||||
|
||||
public static function playTreasureEggUnwrap() : void
|
||||
{
|
||||
if(!_hasLoadedGiftUnwrapSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TreasureGoldenEgg");
|
||||
}
|
||||
|
||||
public static function get hasLoadedJourneyBookWorldSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedJourneyBookWorldSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedJourneyBookWorldSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedJourneyBookWorldSfx = param1;
|
||||
}
|
||||
|
||||
public static function playJBPrizeEarned() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookWorldSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBPrizeEarned");
|
||||
}
|
||||
|
||||
public static function playJBWorldFactClose() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookWorldSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBWorldFactClose");
|
||||
}
|
||||
|
||||
public static function playJBWorldFactOpen() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookWorldSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBWorldFactOpen");
|
||||
}
|
||||
|
||||
public static function get hasLoadedJourneyBookBookSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedJourneyBookBookSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedJourneyBookBookSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedJourneyBookBookSfx = param1;
|
||||
}
|
||||
|
||||
public static function playJBBookFactClose() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookBookSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBBookFactClose");
|
||||
}
|
||||
|
||||
public static function playJBBookFactOpen() : void
|
||||
{
|
||||
if(!_hasLoadedJourneyBookBookSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("JBBookFactOpen");
|
||||
}
|
||||
|
||||
public static function get hasLoadedTradeSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedTradeSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedTradeSfx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedTradeSfx = param1;
|
||||
}
|
||||
|
||||
public static function playTradeSuccessSound() : void
|
||||
{
|
||||
if(!_hasLoadedTradeSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TradeSuccessSound");
|
||||
}
|
||||
|
||||
public static function playTradeFailedSound() : void
|
||||
{
|
||||
if(!_hasLoadedTradeSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TradeFailedSound");
|
||||
}
|
||||
|
||||
public static function playTradeRequestSound() : void
|
||||
{
|
||||
if(!_hasLoadedTradeSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("TradeRequestSound");
|
||||
}
|
||||
|
||||
public static function get hasLoadedPetCreateSfx() : Boolean
|
||||
{
|
||||
return _hasLoadedPetCreateSfx;
|
||||
}
|
||||
|
||||
public static function set hasLoadedPetCreatefx(param1:Boolean) : void
|
||||
{
|
||||
_hasLoadedPetCreateSfx = param1;
|
||||
}
|
||||
|
||||
public static function playPetCreateRandomSound1() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("petRandomization1");
|
||||
}
|
||||
|
||||
public static function stopPetCreateRandomSound1() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stopSfx("petRandomization1");
|
||||
}
|
||||
|
||||
public static function playPetCreateRandomSound2() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("petRandomization2");
|
||||
}
|
||||
|
||||
public static function stopPetCreateRandomSound2() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stopSfx("petRandomization2");
|
||||
}
|
||||
|
||||
public static function playPetCreateRandomSound3() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("petRandomization3");
|
||||
}
|
||||
|
||||
public static function stopPetCreateRandomSound3() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stopSfx("petRandomization3");
|
||||
}
|
||||
|
||||
public static function playPetCreateRandomSound4() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("petRandomization4");
|
||||
}
|
||||
|
||||
public static function stopPetCreateRandomSound4() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stopSfx("petRandomization4");
|
||||
}
|
||||
|
||||
public static function playPetCreateRandomSoundFinish() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
playSfx("petRandomizationFinish");
|
||||
}
|
||||
|
||||
public static function stopPetCreateRandomSoundFinish() : void
|
||||
{
|
||||
if(!_hasLoadedPetCreateSfx)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stopSfx("petRandomizationFinish");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.loader.ResourceStack;
|
||||
import com.sbi.popup.SBStandardPopup;
|
||||
import createAccountFlow.CreateAccount;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.events.UncaughtErrorEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.system.Capabilities;
|
||||
import flash.system.Security;
|
||||
import flash.ui.Mouse;
|
||||
import gamePlayFlow.GamePlay;
|
||||
import gui.DarkenManager;
|
||||
import loadProgress.LoadProgress;
|
||||
import loader.DefPacksDefHelper;
|
||||
import localization.LocalizationManager;
|
||||
import resource.LoadAvatarCarouselResourceStackable;
|
||||
import resource.LoadCursorResourceStackable;
|
||||
import room.DebugGUITextbox;
|
||||
import waitingRoomFlow.WaitingRoom;
|
||||
|
||||
[SWF(width="900", height="550", backgroundColor="#393625", frameRate="24")]
|
||||
public class AJClient extends Sprite
|
||||
{
|
||||
|
||||
private static var _globalDebugLog:DebugGUITextbox;
|
||||
|
||||
private var _resourceStackLoader:ResourceStack;
|
||||
|
||||
public function AJClient()
|
||||
{
|
||||
super();
|
||||
addEventListener("addedToStage",addedToStageHandler);
|
||||
}
|
||||
|
||||
public static function get globalDebugLog() : DebugGUITextbox
|
||||
{
|
||||
return _globalDebugLog;
|
||||
}
|
||||
|
||||
private function addedToStageHandler(param1:Event) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc3_:int = 0;
|
||||
removeEventListener("addedToStage",addedToStageHandler);
|
||||
if(Capabilities.playerType != "Desktop")
|
||||
{
|
||||
Security.allowDomain("*");
|
||||
Security.allowInsecureDomain("*");
|
||||
}
|
||||
var _loc4_:Boolean = ExternalInterface.available;
|
||||
if(_loc4_)
|
||||
{
|
||||
DebugUtility.debugTrace("addedToStageHandler - extIntAvail is true");
|
||||
DebugUtility.debugTrace("mrc dm init ctor starting up call returned:" + ExternalInterface.call("mrc",["dm","AJClient addedToStageHandler starting up"]));
|
||||
ExternalInterface.call("handleGAEvent","flashStarted");
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("addedToStageHandler - extIntAvail is false");
|
||||
}
|
||||
if(!MainFrame.isInitialized())
|
||||
{
|
||||
if(parent != null)
|
||||
{
|
||||
if(parent.hasOwnProperty("flashVars"))
|
||||
{
|
||||
_loc2_ = parent["flashVars"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = parent.loaderInfo.parameters;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = loaderInfo.parameters;
|
||||
}
|
||||
DebugUtility.debugTrace("addedToStageHandler - printing loaderInfo parameters flashvars...");
|
||||
_loc3_ = 0;
|
||||
for(var _loc5_:String in _loc2_)
|
||||
{
|
||||
DebugUtility.debugTrace(" flashvar " + _loc5_ + ":" + _loc2_[_loc5_]);
|
||||
_loc3_++;
|
||||
}
|
||||
DebugUtility.debugTrace("addedToStageHandler - ...done printing loaderInfo parameters flashvars - i:" + _loc3_);
|
||||
MainFrame.handleLocalExternalCall = GamePlay.handleLocalExternalCall;
|
||||
MainFrame.getInstance(_loc2_,setupInit,"",this);
|
||||
LoadProgress.updateProgress(2);
|
||||
_globalDebugLog = new DebugGUITextbox(this,"","Debug Log [F4]",false,true,true,750,276,true);
|
||||
_globalDebugLog.x = 80;
|
||||
_globalDebugLog.y = 50;
|
||||
DebugUtility.setDebugGUIHandler(_globalDebugLog.appendHtml);
|
||||
loaderInfo.uncaughtErrorEvents.addEventListener("uncaughtError",handleGlobalErrors);
|
||||
}
|
||||
DebugUtility.debugTrace("AJClient addedToStageHandler finished");
|
||||
}
|
||||
|
||||
public function setupInit() : void
|
||||
{
|
||||
gMainFrame.stage.addEventListener("Localization",LocalizationManager.onLocalizationEvent,false,0,true);
|
||||
LocalizationManager.currentLanguage = LocalizationManager.accountLanguage = LocalizationManager.getLanguageIdForLocale(gMainFrame.clientInfo.locale);
|
||||
LocalizationManager.countryCode = gMainFrame.clientInfo.countryCode;
|
||||
var _loc1_:DefPacksDefHelper = new DefPacksDefHelper();
|
||||
_loc1_.init(uint("1023" + LocalizationManager.currentLanguage),LocalizationXtCommManager.onLocalizationListResponse,loadResourceItems,2);
|
||||
DefPacksDefHelper.mediaArray["1023" + LocalizationManager.currentLanguage] = _loc1_;
|
||||
_loc1_ = new DefPacksDefHelper();
|
||||
_loc1_.init(uint("1055" + LocalizationManager.accountLanguage),LocalizationXtCommManager.onPreferredLocalizationListResponse,null,2);
|
||||
DefPacksDefHelper.mediaArray["1055" + LocalizationManager.accountLanguage] = _loc1_;
|
||||
}
|
||||
|
||||
public function loadResourceItems() : void
|
||||
{
|
||||
LoadProgress.updateProgress(3);
|
||||
Utility.init(DarkenManager.showLoadingSpiral,DarkenManager.darken,DarkenManager.unDarken);
|
||||
_resourceStackLoader = new ResourceStack(gMainFrame.path,gMainFrame.loaderCache.openFile);
|
||||
_resourceStackLoader.pushFile("assets/sharedFonts.swf",true);
|
||||
_resourceStackLoader.pushFile("assets/HUDAssets.swf",true);
|
||||
if(gMainFrame.clientInfo.isCreateAccount)
|
||||
{
|
||||
_resourceStackLoader.pushClass(new LoadAvatarCarouselResourceStackable());
|
||||
}
|
||||
if(Mouse["supportsNativeCursor"])
|
||||
{
|
||||
_resourceStackLoader.pushClass(new LoadCursorResourceStackable());
|
||||
}
|
||||
if(ExternalInterface.available)
|
||||
{
|
||||
ExternalInterface.call("aj_initialized");
|
||||
}
|
||||
if("failedToInitiate" in gMainFrame.clientInfo && gMainFrame.clientInfo.failedToInitiate == true)
|
||||
{
|
||||
_resourceStackLoader.start(onInitiationFailure);
|
||||
}
|
||||
else if(gMainFrame.clientInfo.isCreateAccount)
|
||||
{
|
||||
_resourceStackLoader.start(setupCreateAccount);
|
||||
}
|
||||
else if(gMainFrame.clientInfo.waitingMode)
|
||||
{
|
||||
_resourceStackLoader.start(setupWaitingRoom);
|
||||
}
|
||||
else
|
||||
{
|
||||
_resourceStackLoader.start(setupGamePlay);
|
||||
}
|
||||
}
|
||||
|
||||
public function setupCreateAccount() : void
|
||||
{
|
||||
var _loc1_:CreateAccount = new CreateAccount(gMainFrame.clientInfo);
|
||||
addChild(_loc1_);
|
||||
gMainFrame.createAccount = _loc1_;
|
||||
_loc1_.loginCtorHelper();
|
||||
}
|
||||
|
||||
public function setupWaitingRoom() : void
|
||||
{
|
||||
var _loc1_:WaitingRoom = new WaitingRoom(gMainFrame.clientInfo);
|
||||
addChild(_loc1_);
|
||||
gMainFrame.waitingRoom = _loc1_;
|
||||
_loc1_.waitCtorHelper();
|
||||
}
|
||||
|
||||
public function setupGamePlay(param1:Event = null, param2:Event = null) : void
|
||||
{
|
||||
DebugUtility.debugTrace("setupGamePlay - loginEvt:" + param1 + " connectEvt:" + param2);
|
||||
if(gMainFrame.createAccount)
|
||||
{
|
||||
if(contains(gMainFrame.createAccount))
|
||||
{
|
||||
removeChild(gMainFrame.createAccount);
|
||||
}
|
||||
gMainFrame.createAccount = null;
|
||||
_resourceStackLoader = null;
|
||||
}
|
||||
DebugUtility.debugTrace("setupGamePlay - constructing GamePlay - gMainFrame.clientInfo:" + gMainFrame.clientInfo);
|
||||
var _loc3_:GamePlay = new GamePlay(gMainFrame.clientInfo,param1,param2);
|
||||
addChild(_loc3_);
|
||||
gMainFrame.gamePlay = _loc3_;
|
||||
DebugUtility.debugTrace("setupGamePlay - gp:" + _loc3_ + " calling worldCtorHelper");
|
||||
_loc3_.worldCtorHelper();
|
||||
}
|
||||
|
||||
private function onInitiationFailure() : void
|
||||
{
|
||||
new SBStandardPopup(gMainFrame.stage,LocalizationManager.translateIdOnly(11202),false);
|
||||
}
|
||||
|
||||
private function createAvatar() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function shardSelection() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function enterGame() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function handleGlobalErrors(param1:UncaughtErrorEvent) : void
|
||||
{
|
||||
GlobalErrorCatch.globalErrorListener(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class ClipVertex
|
||||
{
|
||||
|
||||
public var v:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var id:b2ContactID = new b2ContactID();
|
||||
|
||||
public function ClipVertex()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
public class Features
|
||||
{
|
||||
|
||||
public var _referenceEdge:int;
|
||||
|
||||
public var _incidentEdge:int;
|
||||
|
||||
public var _incidentVertex:int;
|
||||
|
||||
public var _flip:int;
|
||||
|
||||
public var _m_id:b2ContactID;
|
||||
|
||||
public function Features()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function set referenceEdge(param1:int) : void
|
||||
{
|
||||
_referenceEdge = param1;
|
||||
_m_id._key = _m_id._key & 0xFFFFFF00 | _referenceEdge & 0xFF;
|
||||
}
|
||||
|
||||
public function get referenceEdge() : int
|
||||
{
|
||||
return _referenceEdge;
|
||||
}
|
||||
|
||||
public function set incidentEdge(param1:int) : void
|
||||
{
|
||||
_incidentEdge = param1;
|
||||
_m_id._key = _m_id._key & 0xFFFF00FF | _incidentEdge << 8 & 0xFF00;
|
||||
}
|
||||
|
||||
public function get incidentEdge() : int
|
||||
{
|
||||
return _incidentEdge;
|
||||
}
|
||||
|
||||
public function set incidentVertex(param1:int) : void
|
||||
{
|
||||
_incidentVertex = param1;
|
||||
_m_id._key = _m_id._key & 0xFF00FFFF | _incidentVertex << 16 & 0xFF0000;
|
||||
}
|
||||
|
||||
public function get incidentVertex() : int
|
||||
{
|
||||
return _incidentVertex;
|
||||
}
|
||||
|
||||
public function set flip(param1:int) : void
|
||||
{
|
||||
_flip = param1;
|
||||
_m_id._key = _m_id._key & 0xFFFFFF | _flip << 24 & 0xFF000000;
|
||||
}
|
||||
|
||||
public function get flip() : int
|
||||
{
|
||||
return _flip;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package Box2D.Collision.Shapes
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2CircleDef extends b2ShapeDef
|
||||
{
|
||||
|
||||
public var localPosition:b2Vec2 = new b2Vec2(0,0);
|
||||
|
||||
public var radius:Number;
|
||||
|
||||
public function b2CircleDef()
|
||||
{
|
||||
super();
|
||||
type = 0;
|
||||
radius = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package Box2D.Collision.Shapes
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.*;
|
||||
|
||||
public class b2CircleShape extends b2Shape
|
||||
{
|
||||
|
||||
public var m_localPosition:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_radius:Number;
|
||||
|
||||
public function b2CircleShape(param1:b2ShapeDef)
|
||||
{
|
||||
super(param1);
|
||||
var _loc2_:b2CircleDef = param1 as b2CircleDef;
|
||||
m_type = 0;
|
||||
m_localPosition.SetV(_loc2_.localPosition);
|
||||
m_radius = _loc2_.radius;
|
||||
}
|
||||
|
||||
override public function TestPoint(param1:b2XForm, param2:b2Vec2) : Boolean
|
||||
{
|
||||
var _loc5_:b2Mat22 = param1.R;
|
||||
var _loc3_:Number = param1.position.x + (_loc5_.col1.x * m_localPosition.x + _loc5_.col2.x * m_localPosition.y);
|
||||
var _loc4_:Number = param1.position.y + (_loc5_.col1.y * m_localPosition.x + _loc5_.col2.y * m_localPosition.y);
|
||||
_loc3_ = param2.x - _loc3_;
|
||||
_loc4_ = param2.y - _loc4_;
|
||||
return _loc3_ * _loc3_ + _loc4_ * _loc4_ <= m_radius * m_radius;
|
||||
}
|
||||
|
||||
override public function TestSegment(param1:b2XForm, param2:Array, param3:b2Vec2, param4:b2Segment, param5:Number) : Boolean
|
||||
{
|
||||
var _loc17_:b2Mat22 = param1.R;
|
||||
var _loc15_:Number = param1.position.x + (_loc17_.col1.x * m_localPosition.x + _loc17_.col2.x * m_localPosition.y);
|
||||
var _loc16_:Number = param1.position.y + (_loc17_.col1.y * m_localPosition.x + _loc17_.col2.y * m_localPosition.y);
|
||||
var _loc11_:Number = param4.p1.x - _loc15_;
|
||||
var _loc12_:Number = param4.p1.y - _loc16_;
|
||||
var _loc9_:Number = _loc11_ * _loc11_ + _loc12_ * _loc12_ - m_radius * m_radius;
|
||||
if(_loc9_ < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc13_:Number = param4.p2.x - param4.p1.x;
|
||||
var _loc14_:Number = param4.p2.y - param4.p1.y;
|
||||
var _loc10_:Number = _loc11_ * _loc13_ + _loc12_ * _loc14_;
|
||||
var _loc6_:Number = _loc13_ * _loc13_ + _loc14_ * _loc14_;
|
||||
var _loc7_:Number = _loc10_ * _loc10_ - _loc6_ * _loc9_;
|
||||
if(_loc7_ < 0 || _loc6_ < Number.MIN_VALUE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc8_:Number = -(_loc10_ + Math.sqrt(_loc7_));
|
||||
if(0 <= _loc8_ && _loc8_ <= param5 * _loc6_)
|
||||
{
|
||||
_loc8_ /= _loc6_;
|
||||
param2[0] = _loc8_;
|
||||
param3.x = _loc11_ + _loc8_ * _loc13_;
|
||||
param3.y = _loc12_ + _loc8_ * _loc14_;
|
||||
param3.Normalize();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function ComputeAABB(param1:b2AABB, param2:b2XForm) : void
|
||||
{
|
||||
var _loc4_:b2Mat22 = param2.R;
|
||||
var _loc3_:Number = param2.position.x + (_loc4_.col1.x * m_localPosition.x + _loc4_.col2.x * m_localPosition.y);
|
||||
var _loc5_:Number = param2.position.y + (_loc4_.col1.y * m_localPosition.x + _loc4_.col2.y * m_localPosition.y);
|
||||
param1.lowerBound.Set(_loc3_ - m_radius,_loc5_ - m_radius);
|
||||
param1.upperBound.Set(_loc3_ + m_radius,_loc5_ + m_radius);
|
||||
}
|
||||
|
||||
override public function ComputeSweptAABB(param1:b2AABB, param2:b2XForm, param3:b2XForm) : void
|
||||
{
|
||||
var _loc7_:b2Mat22 = null;
|
||||
_loc7_ = param2.R;
|
||||
var _loc4_:Number = param2.position.x + (_loc7_.col1.x * m_localPosition.x + _loc7_.col2.x * m_localPosition.y);
|
||||
var _loc8_:Number = param2.position.y + (_loc7_.col1.y * m_localPosition.x + _loc7_.col2.y * m_localPosition.y);
|
||||
_loc7_ = param3.R;
|
||||
var _loc6_:Number = param3.position.x + (_loc7_.col1.x * m_localPosition.x + _loc7_.col2.x * m_localPosition.y);
|
||||
var _loc5_:Number = param3.position.y + (_loc7_.col1.y * m_localPosition.x + _loc7_.col2.y * m_localPosition.y);
|
||||
param1.lowerBound.Set((_loc4_ < _loc6_ ? _loc4_ : _loc6_) - m_radius,(_loc8_ < _loc5_ ? _loc8_ : _loc5_) - m_radius);
|
||||
param1.upperBound.Set((_loc4_ > _loc6_ ? _loc4_ : _loc6_) + m_radius,(_loc8_ > _loc5_ ? _loc8_ : _loc5_) + m_radius);
|
||||
}
|
||||
|
||||
override public function ComputeMass(param1:b2MassData) : void
|
||||
{
|
||||
param1.mass = m_density * 3.141592653589793 * m_radius * m_radius;
|
||||
param1.center.SetV(m_localPosition);
|
||||
param1.I = param1.mass * (0.5 * m_radius * m_radius + (m_localPosition.x * m_localPosition.x + m_localPosition.y * m_localPosition.y));
|
||||
}
|
||||
|
||||
public function GetLocalPosition() : b2Vec2
|
||||
{
|
||||
return m_localPosition;
|
||||
}
|
||||
|
||||
public function GetRadius() : Number
|
||||
{
|
||||
return m_radius;
|
||||
}
|
||||
|
||||
override public function UpdateSweepRadius(param1:b2Vec2) : void
|
||||
{
|
||||
var _loc2_:Number = m_localPosition.x - param1.x;
|
||||
var _loc3_:Number = m_localPosition.y - param1.y;
|
||||
_loc2_ = Math.sqrt(_loc2_ * _loc2_ + _loc3_ * _loc3_);
|
||||
m_sweepRadius = _loc2_ + m_radius - 0.04;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package Box2D.Collision.Shapes
|
||||
{
|
||||
public class b2FilterData
|
||||
{
|
||||
|
||||
public var categoryBits:uint = 1;
|
||||
|
||||
public var maskBits:uint = 65535;
|
||||
|
||||
public var groupIndex:int = 0;
|
||||
|
||||
public function b2FilterData()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function Copy() : b2FilterData
|
||||
{
|
||||
var _loc1_:b2FilterData = new b2FilterData();
|
||||
_loc1_.categoryBits = categoryBits;
|
||||
_loc1_.maskBits = maskBits;
|
||||
_loc1_.groupIndex = groupIndex;
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package Box2D.Collision.Shapes
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2MassData
|
||||
{
|
||||
|
||||
public var mass:Number = 0;
|
||||
|
||||
public var center:b2Vec2 = new b2Vec2(0,0);
|
||||
|
||||
public var I:Number = 0;
|
||||
|
||||
public function b2MassData()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package Box2D.Collision.Shapes
|
||||
{
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
|
||||
public class b2PolygonDef extends b2ShapeDef
|
||||
{
|
||||
|
||||
private static var s_mat:b2Mat22 = new b2Mat22();
|
||||
|
||||
public var vertices:Array = new Array(8);
|
||||
|
||||
public var vertexCount:int;
|
||||
|
||||
public function b2PolygonDef()
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
super();
|
||||
type = 1;
|
||||
vertexCount = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 8)
|
||||
{
|
||||
vertices[_loc1_] = new b2Vec2();
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function SetAsBox(param1:Number, param2:Number) : void
|
||||
{
|
||||
vertexCount = 4;
|
||||
vertices[0].Set(-param1,-param2);
|
||||
vertices[1].Set(param1,-param2);
|
||||
vertices[2].Set(param1,param2);
|
||||
vertices[3].Set(-param1,param2);
|
||||
}
|
||||
|
||||
public function SetAsOrientedBox(param1:Number, param2:Number, param3:b2Vec2 = null, param4:Number = 0) : void
|
||||
{
|
||||
var _loc6_:b2Vec2 = null;
|
||||
var _loc5_:b2Mat22 = null;
|
||||
var _loc7_:int = 0;
|
||||
vertexCount = 4;
|
||||
vertices[0].Set(-param1,-param2);
|
||||
vertices[1].Set(param1,-param2);
|
||||
vertices[2].Set(param1,param2);
|
||||
vertices[3].Set(-param1,param2);
|
||||
if(param3)
|
||||
{
|
||||
_loc6_ = param3;
|
||||
_loc5_ = s_mat;
|
||||
_loc5_.Set(param4);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < vertexCount)
|
||||
{
|
||||
param3 = vertices[_loc7_];
|
||||
param1 = _loc6_.x + (_loc5_.col1.x * param3.x + _loc5_.col2.x * param3.y);
|
||||
param3.y = _loc6_.y + (_loc5_.col1.y * param3.x + _loc5_.col2.y * param3.y);
|
||||
param3.x = param1;
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,492 @@
|
||||
package Box2D.Collision.Shapes
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.*;
|
||||
|
||||
public class b2PolygonShape extends b2Shape
|
||||
{
|
||||
|
||||
private static var s_computeMat:b2Mat22 = new b2Mat22();
|
||||
|
||||
private static var s_sweptAABB1:b2AABB = new b2AABB();
|
||||
|
||||
private static var s_sweptAABB2:b2AABB = new b2AABB();
|
||||
|
||||
private var s_supportVec:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_centroid:b2Vec2;
|
||||
|
||||
public var m_obb:b2OBB = new b2OBB();
|
||||
|
||||
public var m_vertices:Array = new Array(8);
|
||||
|
||||
public var m_normals:Array = new Array(8);
|
||||
|
||||
public var m_coreVertices:Array = new Array(8);
|
||||
|
||||
public var m_vertexCount:int;
|
||||
|
||||
public function b2PolygonShape(param1:b2ShapeDef)
|
||||
{
|
||||
var _loc7_:int = 0;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
super(param1);
|
||||
m_type = 1;
|
||||
var _loc17_:b2PolygonDef = param1 as b2PolygonDef;
|
||||
m_vertexCount = _loc17_.vertexCount;
|
||||
var _loc6_:int = _loc7_;
|
||||
var _loc8_:int = _loc7_;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_vertexCount)
|
||||
{
|
||||
m_vertices[_loc7_] = _loc17_.vertices[_loc7_].Copy();
|
||||
_loc7_++;
|
||||
}
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_vertexCount)
|
||||
{
|
||||
_loc6_ = _loc7_;
|
||||
_loc8_ = _loc7_ + 1 < m_vertexCount ? _loc7_ + 1 : 0;
|
||||
_loc5_ = m_vertices[_loc8_].x - m_vertices[_loc6_].x;
|
||||
_loc2_ = m_vertices[_loc8_].y - m_vertices[_loc6_].y;
|
||||
_loc10_ = Math.sqrt(_loc5_ * _loc5_ + _loc2_ * _loc2_);
|
||||
m_normals[_loc7_] = new b2Vec2(_loc2_ / _loc10_,-_loc5_ / _loc10_);
|
||||
_loc7_++;
|
||||
}
|
||||
m_centroid = ComputeCentroid(_loc17_.vertices,_loc17_.vertexCount);
|
||||
ComputeOBB(m_obb,m_vertices,m_vertexCount);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_vertexCount)
|
||||
{
|
||||
_loc6_ = _loc7_ - 1 >= 0 ? _loc7_ - 1 : m_vertexCount - 1;
|
||||
_loc8_ = _loc7_;
|
||||
_loc11_ = Number(m_normals[_loc6_].x);
|
||||
_loc16_ = Number(m_normals[_loc6_].y);
|
||||
_loc14_ = Number(m_normals[_loc8_].x);
|
||||
_loc12_ = Number(m_normals[_loc8_].y);
|
||||
_loc3_ = m_vertices[_loc7_].x - m_centroid.x;
|
||||
_loc4_ = m_vertices[_loc7_].y - m_centroid.y;
|
||||
_loc13_ = _loc11_ * _loc3_ + _loc16_ * _loc4_ - 0.04;
|
||||
_loc15_ = _loc14_ * _loc3_ + _loc12_ * _loc4_ - 0.04;
|
||||
_loc9_ = 1 / (_loc11_ * _loc12_ - _loc16_ * _loc14_);
|
||||
m_coreVertices[_loc7_] = new b2Vec2(_loc9_ * (_loc12_ * _loc13_ - _loc16_ * _loc15_) + m_centroid.x,_loc9_ * (_loc11_ * _loc15_ - _loc14_ * _loc13_) + m_centroid.y);
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
|
||||
public static function ComputeCentroid(param1:Array, param2:int) : b2Vec2
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc4_:b2Vec2 = null;
|
||||
var _loc6_:b2Vec2 = null;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc5_:b2Vec2 = new b2Vec2();
|
||||
var _loc3_:Number = 0;
|
||||
var _loc15_:Number = 0;
|
||||
var _loc16_:Number = 0;
|
||||
var _loc13_:Number = 0.3333333333333333;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param2)
|
||||
{
|
||||
_loc4_ = param1[_loc8_];
|
||||
_loc6_ = _loc8_ + 1 < param2 ? param1[int(_loc8_ + 1)] : param1[0];
|
||||
_loc11_ = _loc4_.x - _loc15_;
|
||||
_loc10_ = _loc4_.y - _loc16_;
|
||||
_loc9_ = _loc6_.x - _loc15_;
|
||||
_loc12_ = _loc6_.y - _loc16_;
|
||||
_loc7_ = _loc11_ * _loc12_ - _loc10_ * _loc9_;
|
||||
_loc14_ = 0.5 * _loc7_;
|
||||
_loc3_ += _loc14_;
|
||||
_loc5_.x += _loc14_ * _loc13_ * (_loc15_ + _loc4_.x + _loc6_.x);
|
||||
_loc5_.y += _loc14_ * _loc13_ * (_loc16_ + _loc4_.y + _loc6_.y);
|
||||
_loc8_++;
|
||||
}
|
||||
_loc5_.x *= 1 / _loc3_;
|
||||
_loc5_.y *= 1 / _loc3_;
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
public static function ComputeOBB(param1:b2OBB, param2:Array, param3:int) : void
|
||||
{
|
||||
var _loc16_:int = 0;
|
||||
var _loc7_:b2Vec2 = null;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc23_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc17_:int = 0;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc24_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc25_:b2Mat22 = null;
|
||||
var _loc18_:Array = new Array(8 + 1);
|
||||
_loc16_ = 0;
|
||||
while(_loc16_ < param3)
|
||||
{
|
||||
_loc18_[_loc16_] = param2[_loc16_];
|
||||
_loc16_++;
|
||||
}
|
||||
_loc18_[param3] = _loc18_[0];
|
||||
var _loc9_:Number = 1.7976931348623157e+308;
|
||||
_loc16_ = 1;
|
||||
while(_loc16_ <= param3)
|
||||
{
|
||||
_loc7_ = _loc18_[int(_loc16_ - 1)];
|
||||
_loc6_ = _loc18_[_loc16_].x - _loc7_.x;
|
||||
_loc8_ = _loc18_[_loc16_].y - _loc7_.y;
|
||||
_loc14_ = Math.sqrt(_loc6_ * _loc6_ + _loc8_ * _loc8_);
|
||||
_loc6_ /= _loc14_;
|
||||
_loc8_ /= _loc14_;
|
||||
_loc23_ = -_loc8_;
|
||||
_loc21_ = _loc6_;
|
||||
_loc15_ = 1.7976931348623157e+308;
|
||||
_loc12_ = 1.7976931348623157e+308;
|
||||
_loc20_ = -1.7976931348623157e+308;
|
||||
_loc19_ = -1.7976931348623157e+308;
|
||||
_loc17_ = 0;
|
||||
while(_loc17_ < param3)
|
||||
{
|
||||
_loc22_ = _loc18_[_loc17_].x - _loc7_.x;
|
||||
_loc24_ = _loc18_[_loc17_].y - _loc7_.y;
|
||||
_loc11_ = _loc6_ * _loc22_ + _loc8_ * _loc24_;
|
||||
_loc13_ = _loc23_ * _loc22_ + _loc21_ * _loc24_;
|
||||
if(_loc11_ < _loc15_)
|
||||
{
|
||||
_loc15_ = _loc11_;
|
||||
}
|
||||
if(_loc13_ < _loc12_)
|
||||
{
|
||||
_loc12_ = _loc13_;
|
||||
}
|
||||
if(_loc11_ > _loc20_)
|
||||
{
|
||||
_loc20_ = _loc11_;
|
||||
}
|
||||
if(_loc13_ > _loc19_)
|
||||
{
|
||||
_loc19_ = _loc13_;
|
||||
}
|
||||
_loc17_++;
|
||||
}
|
||||
_loc10_ = (_loc20_ - _loc15_) * (_loc19_ - _loc12_);
|
||||
if(_loc10_ < 0.95 * _loc9_)
|
||||
{
|
||||
_loc9_ = _loc10_;
|
||||
param1.R.col1.x = _loc6_;
|
||||
param1.R.col1.y = _loc8_;
|
||||
param1.R.col2.x = _loc23_;
|
||||
param1.R.col2.y = _loc21_;
|
||||
_loc5_ = 0.5 * (_loc15_ + _loc20_);
|
||||
_loc4_ = 0.5 * (_loc12_ + _loc19_);
|
||||
_loc25_ = param1.R;
|
||||
param1.center.x = _loc7_.x + (_loc25_.col1.x * _loc5_ + _loc25_.col2.x * _loc4_);
|
||||
param1.center.y = _loc7_.y + (_loc25_.col1.y * _loc5_ + _loc25_.col2.y * _loc4_);
|
||||
param1.extents.x = 0.5 * (_loc20_ - _loc15_);
|
||||
param1.extents.y = 0.5 * (_loc19_ - _loc12_);
|
||||
}
|
||||
_loc16_++;
|
||||
}
|
||||
}
|
||||
|
||||
override public function TestPoint(param1:b2XForm, param2:b2Vec2) : Boolean
|
||||
{
|
||||
var _loc5_:b2Vec2 = null;
|
||||
var _loc9_:int = 0;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:b2Mat22 = param1.R;
|
||||
var _loc3_:Number = param2.x - param1.position.x;
|
||||
var _loc4_:Number = param2.y - param1.position.y;
|
||||
var _loc8_:Number = _loc3_ * _loc7_.col1.x + _loc4_ * _loc7_.col1.y;
|
||||
var _loc10_:Number = _loc3_ * _loc7_.col2.x + _loc4_ * _loc7_.col2.y;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < m_vertexCount)
|
||||
{
|
||||
_loc5_ = m_vertices[_loc9_];
|
||||
_loc3_ = _loc8_ - _loc5_.x;
|
||||
_loc4_ = _loc10_ - _loc5_.y;
|
||||
_loc5_ = m_normals[_loc9_];
|
||||
_loc6_ = _loc5_.x * _loc3_ + _loc5_.y * _loc4_;
|
||||
if(_loc6_ > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
override public function TestSegment(param1:b2XForm, param2:Array, param3:b2Vec2, param4:b2Segment, param5:Number) : Boolean
|
||||
{
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc20_:b2Mat22 = null;
|
||||
var _loc16_:b2Vec2 = null;
|
||||
var _loc11_:int = 0;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc8_:Number = 0;
|
||||
var _loc9_:Number = param5;
|
||||
_loc6_ = param4.p1.x - param1.position.x;
|
||||
_loc7_ = param4.p1.y - param1.position.y;
|
||||
_loc20_ = param1.R;
|
||||
var _loc17_:Number = _loc6_ * _loc20_.col1.x + _loc7_ * _loc20_.col1.y;
|
||||
var _loc21_:Number = _loc6_ * _loc20_.col2.x + _loc7_ * _loc20_.col2.y;
|
||||
_loc6_ = param4.p2.x - param1.position.x;
|
||||
_loc7_ = param4.p2.y - param1.position.y;
|
||||
_loc20_ = param1.R;
|
||||
var _loc19_:Number = _loc6_ * _loc20_.col1.x + _loc7_ * _loc20_.col1.y;
|
||||
var _loc18_:Number = _loc6_ * _loc20_.col2.x + _loc7_ * _loc20_.col2.y;
|
||||
var _loc14_:Number = _loc19_ - _loc17_;
|
||||
var _loc15_:Number = _loc18_ - _loc21_;
|
||||
var _loc10_:* = -1;
|
||||
_loc11_ = 0;
|
||||
while(_loc11_ < m_vertexCount)
|
||||
{
|
||||
_loc16_ = m_vertices[_loc11_];
|
||||
_loc6_ = _loc16_.x - _loc17_;
|
||||
_loc7_ = _loc16_.y - _loc21_;
|
||||
_loc16_ = m_normals[_loc11_];
|
||||
_loc12_ = _loc16_.x * _loc6_ + _loc16_.y * _loc7_;
|
||||
_loc13_ = _loc16_.x * _loc14_ + _loc16_.y * _loc15_;
|
||||
if(_loc13_ < 0 && _loc12_ < _loc8_ * _loc13_)
|
||||
{
|
||||
_loc8_ = _loc12_ / _loc13_;
|
||||
_loc10_ = _loc11_;
|
||||
}
|
||||
else if(_loc13_ > 0 && _loc12_ < _loc9_ * _loc13_)
|
||||
{
|
||||
_loc9_ = _loc12_ / _loc13_;
|
||||
}
|
||||
if(_loc9_ < _loc8_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc11_++;
|
||||
}
|
||||
if(_loc10_ >= 0)
|
||||
{
|
||||
param2[0] = _loc8_;
|
||||
_loc20_ = param1.R;
|
||||
_loc16_ = m_normals[_loc10_];
|
||||
param3.x = _loc20_.col1.x * _loc16_.x + _loc20_.col2.x * _loc16_.y;
|
||||
param3.y = _loc20_.col1.y * _loc16_.x + _loc20_.col2.y * _loc16_.y;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function ComputeAABB(param1:b2AABB, param2:b2XForm) : void
|
||||
{
|
||||
var _loc8_:b2Mat22 = null;
|
||||
var _loc7_:b2Vec2 = null;
|
||||
var _loc6_:b2Mat22 = s_computeMat;
|
||||
_loc8_ = param2.R;
|
||||
_loc7_ = m_obb.R.col1;
|
||||
_loc6_.col1.x = _loc8_.col1.x * _loc7_.x + _loc8_.col2.x * _loc7_.y;
|
||||
_loc6_.col1.y = _loc8_.col1.y * _loc7_.x + _loc8_.col2.y * _loc7_.y;
|
||||
_loc7_ = m_obb.R.col2;
|
||||
_loc6_.col2.x = _loc8_.col1.x * _loc7_.x + _loc8_.col2.x * _loc7_.y;
|
||||
_loc6_.col2.y = _loc8_.col1.y * _loc7_.x + _loc8_.col2.y * _loc7_.y;
|
||||
_loc6_.Abs();
|
||||
var _loc9_:b2Mat22 = _loc6_;
|
||||
_loc7_ = m_obb.extents;
|
||||
var _loc3_:Number = _loc9_.col1.x * _loc7_.x + _loc9_.col2.x * _loc7_.y;
|
||||
var _loc5_:Number = _loc9_.col1.y * _loc7_.x + _loc9_.col2.y * _loc7_.y;
|
||||
_loc8_ = param2.R;
|
||||
_loc7_ = m_obb.center;
|
||||
var _loc10_:Number = param2.position.x + (_loc8_.col1.x * _loc7_.x + _loc8_.col2.x * _loc7_.y);
|
||||
var _loc4_:Number = param2.position.y + (_loc8_.col1.y * _loc7_.x + _loc8_.col2.y * _loc7_.y);
|
||||
param1.lowerBound.Set(_loc10_ - _loc3_,_loc4_ - _loc5_);
|
||||
param1.upperBound.Set(_loc10_ + _loc3_,_loc4_ + _loc5_);
|
||||
}
|
||||
|
||||
override public function ComputeSweptAABB(param1:b2AABB, param2:b2XForm, param3:b2XForm) : void
|
||||
{
|
||||
var _loc4_:b2AABB = s_sweptAABB1;
|
||||
var _loc5_:b2AABB = s_sweptAABB2;
|
||||
ComputeAABB(_loc4_,param2);
|
||||
ComputeAABB(_loc5_,param3);
|
||||
param1.lowerBound.Set(_loc4_.lowerBound.x < _loc5_.lowerBound.x ? _loc4_.lowerBound.x : _loc5_.lowerBound.x,_loc4_.lowerBound.y < _loc5_.lowerBound.y ? _loc4_.lowerBound.y : _loc5_.lowerBound.y);
|
||||
param1.upperBound.Set(_loc4_.upperBound.x > _loc5_.upperBound.x ? _loc4_.upperBound.x : _loc5_.upperBound.x,_loc4_.upperBound.y > _loc5_.upperBound.y ? _loc4_.upperBound.y : _loc5_.upperBound.y);
|
||||
}
|
||||
|
||||
override public function ComputeMass(param1:b2MassData) : void
|
||||
{
|
||||
var _loc16_:int = 0;
|
||||
var _loc3_:b2Vec2 = null;
|
||||
var _loc4_:b2Vec2 = null;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc24_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc25_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc6_:Number = 0;
|
||||
var _loc2_:Number = 0;
|
||||
var _loc15_:Number = 0;
|
||||
var _loc8_:Number = 0;
|
||||
var _loc22_:Number = 0;
|
||||
var _loc23_:Number = 0;
|
||||
var _loc20_:Number = 0.3333333333333333;
|
||||
_loc16_ = 0;
|
||||
while(_loc16_ < m_vertexCount)
|
||||
{
|
||||
_loc3_ = m_vertices[_loc16_];
|
||||
_loc4_ = _loc16_ + 1 < m_vertexCount ? m_vertices[int(_loc16_ + 1)] : m_vertices[0];
|
||||
_loc18_ = _loc3_.x - _loc22_;
|
||||
_loc17_ = _loc3_.y - _loc23_;
|
||||
_loc10_ = _loc4_.x - _loc22_;
|
||||
_loc11_ = _loc4_.y - _loc23_;
|
||||
_loc5_ = _loc18_ * _loc11_ - _loc17_ * _loc10_;
|
||||
_loc21_ = 0.5 * _loc5_;
|
||||
_loc15_ += _loc21_;
|
||||
_loc6_ += _loc21_ * _loc20_ * (_loc22_ + _loc3_.x + _loc4_.x);
|
||||
_loc2_ += _loc21_ * _loc20_ * (_loc23_ + _loc3_.y + _loc4_.y);
|
||||
_loc7_ = _loc22_;
|
||||
_loc9_ = _loc23_;
|
||||
_loc14_ = _loc18_;
|
||||
_loc24_ = _loc17_;
|
||||
_loc13_ = _loc10_;
|
||||
_loc25_ = _loc11_;
|
||||
_loc12_ = _loc20_ * (0.25 * (_loc14_ * _loc14_ + _loc13_ * _loc14_ + _loc13_ * _loc13_) + (_loc7_ * _loc14_ + _loc7_ * _loc13_)) + 0.5 * _loc7_ * _loc7_;
|
||||
_loc19_ = _loc20_ * (0.25 * (_loc24_ * _loc24_ + _loc25_ * _loc24_ + _loc25_ * _loc25_) + (_loc9_ * _loc24_ + _loc9_ * _loc25_)) + 0.5 * _loc9_ * _loc9_;
|
||||
_loc8_ += _loc5_ * (_loc12_ + _loc19_);
|
||||
_loc16_++;
|
||||
}
|
||||
param1.mass = m_density * _loc15_;
|
||||
_loc6_ *= 1 / _loc15_;
|
||||
_loc2_ *= 1 / _loc15_;
|
||||
param1.center.Set(_loc6_,_loc2_);
|
||||
param1.I = m_density * _loc8_;
|
||||
}
|
||||
|
||||
public function GetOBB() : b2OBB
|
||||
{
|
||||
return m_obb;
|
||||
}
|
||||
|
||||
public function GetCentroid() : b2Vec2
|
||||
{
|
||||
return m_centroid;
|
||||
}
|
||||
|
||||
public function GetVertexCount() : int
|
||||
{
|
||||
return m_vertexCount;
|
||||
}
|
||||
|
||||
public function GetVertices() : Array
|
||||
{
|
||||
return m_vertices;
|
||||
}
|
||||
|
||||
public function GetCoreVertices() : Array
|
||||
{
|
||||
return m_coreVertices;
|
||||
}
|
||||
|
||||
public function GetNormals() : Array
|
||||
{
|
||||
return m_normals;
|
||||
}
|
||||
|
||||
public function GetFirstVertex(param1:b2XForm) : b2Vec2
|
||||
{
|
||||
return b2Math.b2MulX(param1,m_coreVertices[0]);
|
||||
}
|
||||
|
||||
public function Centroid(param1:b2XForm) : b2Vec2
|
||||
{
|
||||
return b2Math.b2MulX(param1,m_centroid);
|
||||
}
|
||||
|
||||
public function Support(param1:b2XForm, param2:Number, param3:Number) : b2Vec2
|
||||
{
|
||||
var _loc4_:b2Vec2 = null;
|
||||
var _loc6_:b2Mat22 = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc10_:Number = NaN;
|
||||
_loc6_ = param1.R;
|
||||
var _loc8_:Number = param2 * _loc6_.col1.x + param3 * _loc6_.col1.y;
|
||||
var _loc5_:Number = param2 * _loc6_.col2.x + param3 * _loc6_.col2.y;
|
||||
var _loc11_:int = 0;
|
||||
_loc4_ = m_coreVertices[0];
|
||||
var _loc9_:Number = _loc4_.x * _loc8_ + _loc4_.y * _loc5_;
|
||||
_loc7_ = 1;
|
||||
while(_loc7_ < m_vertexCount)
|
||||
{
|
||||
_loc4_ = m_coreVertices[_loc7_];
|
||||
_loc10_ = _loc4_.x * _loc8_ + _loc4_.y * _loc5_;
|
||||
if(_loc10_ > _loc9_)
|
||||
{
|
||||
_loc11_ = _loc7_;
|
||||
_loc9_ = _loc10_;
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
_loc6_ = param1.R;
|
||||
_loc4_ = m_coreVertices[_loc11_];
|
||||
s_supportVec.x = param1.position.x + (_loc6_.col1.x * _loc4_.x + _loc6_.col2.x * _loc4_.y);
|
||||
s_supportVec.y = param1.position.y + (_loc6_.col1.y * _loc4_.x + _loc6_.col2.y * _loc4_.y);
|
||||
return s_supportVec;
|
||||
}
|
||||
|
||||
override public function UpdateSweepRadius(param1:b2Vec2) : void
|
||||
{
|
||||
var _loc4_:b2Vec2 = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
m_sweepRadius = 0;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < m_vertexCount)
|
||||
{
|
||||
_loc4_ = m_coreVertices[_loc5_];
|
||||
_loc2_ = _loc4_.x - param1.x;
|
||||
_loc3_ = _loc4_.y - param1.y;
|
||||
_loc2_ = Math.sqrt(_loc2_ * _loc2_ + _loc3_ * _loc3_);
|
||||
if(_loc2_ > m_sweepRadius)
|
||||
{
|
||||
m_sweepRadius = _loc2_;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
package Box2D.Collision.Shapes
|
||||
{
|
||||
import Box2D.Collision.b2AABB;
|
||||
import Box2D.Collision.b2BroadPhase;
|
||||
import Box2D.Collision.b2Pair;
|
||||
import Box2D.Collision.b2Segment;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Common.Math.b2XForm;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
|
||||
public class b2Shape
|
||||
{
|
||||
|
||||
public static const e_unknownShape:int = -1;
|
||||
|
||||
public static const e_circleShape:int = 0;
|
||||
|
||||
public static const e_polygonShape:int = 1;
|
||||
|
||||
public static const e_shapeTypeCount:int = 2;
|
||||
|
||||
private static var s_proxyAABB:b2AABB = new b2AABB();
|
||||
|
||||
private static var s_syncAABB:b2AABB = new b2AABB();
|
||||
|
||||
private static var s_resetAABB:b2AABB = new b2AABB();
|
||||
|
||||
public var m_type:int;
|
||||
|
||||
public var m_next:b2Shape;
|
||||
|
||||
public var m_body:b2Body;
|
||||
|
||||
public var m_sweepRadius:Number;
|
||||
|
||||
public var m_density:Number;
|
||||
|
||||
public var m_friction:Number;
|
||||
|
||||
public var m_restitution:Number;
|
||||
|
||||
public var m_proxyId:uint;
|
||||
|
||||
public var m_filter:b2FilterData;
|
||||
|
||||
public var m_isSensor:Boolean;
|
||||
|
||||
public var m_userData:*;
|
||||
|
||||
public function b2Shape(param1:b2ShapeDef)
|
||||
{
|
||||
super();
|
||||
m_userData = param1.userData;
|
||||
m_friction = param1.friction;
|
||||
m_restitution = param1.restitution;
|
||||
m_density = param1.density;
|
||||
m_body = null;
|
||||
m_sweepRadius = 0;
|
||||
m_next = null;
|
||||
m_proxyId = b2Pair.b2_nullProxy;
|
||||
m_filter = param1.filter.Copy();
|
||||
m_isSensor = param1.isSensor;
|
||||
}
|
||||
|
||||
public static function Create(param1:b2ShapeDef, param2:*) : b2Shape
|
||||
{
|
||||
switch(param1.type)
|
||||
{
|
||||
case e_circleShape:
|
||||
return new b2CircleShape(param1);
|
||||
case 1:
|
||||
return new b2PolygonShape(param1);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static function Destroy(param1:b2Shape, param2:*) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function GetType() : int
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
public function IsSensor() : Boolean
|
||||
{
|
||||
return m_isSensor;
|
||||
}
|
||||
|
||||
public function SetFilterData(param1:b2FilterData) : void
|
||||
{
|
||||
m_filter = param1.Copy();
|
||||
}
|
||||
|
||||
public function GetFilterData() : b2FilterData
|
||||
{
|
||||
return m_filter.Copy();
|
||||
}
|
||||
|
||||
public function GetBody() : b2Body
|
||||
{
|
||||
return m_body;
|
||||
}
|
||||
|
||||
public function GetNext() : b2Shape
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
public function GetUserData() : *
|
||||
{
|
||||
return m_userData;
|
||||
}
|
||||
|
||||
public function SetUserData(param1:*) : void
|
||||
{
|
||||
m_userData = param1;
|
||||
}
|
||||
|
||||
public function TestPoint(param1:b2XForm, param2:b2Vec2) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function TestSegment(param1:b2XForm, param2:Array, param3:b2Vec2, param4:b2Segment, param5:Number) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function ComputeAABB(param1:b2AABB, param2:b2XForm) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function ComputeSweptAABB(param1:b2AABB, param2:b2XForm, param3:b2XForm) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function ComputeMass(param1:b2MassData) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function GetSweepRadius() : Number
|
||||
{
|
||||
return m_sweepRadius;
|
||||
}
|
||||
|
||||
public function GetFriction() : Number
|
||||
{
|
||||
return m_friction;
|
||||
}
|
||||
|
||||
public function GetRestitution() : Number
|
||||
{
|
||||
return m_restitution;
|
||||
}
|
||||
|
||||
public function CreateProxy(param1:b2BroadPhase, param2:b2XForm) : void
|
||||
{
|
||||
var _loc4_:b2AABB = s_proxyAABB;
|
||||
ComputeAABB(_loc4_,param2);
|
||||
var _loc3_:Boolean = param1.InRange(_loc4_);
|
||||
if(_loc3_)
|
||||
{
|
||||
m_proxyId = param1.CreateProxy(_loc4_,this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_proxyId = b2Pair.b2_nullProxy;
|
||||
}
|
||||
}
|
||||
|
||||
public function DestroyProxy(param1:b2BroadPhase) : void
|
||||
{
|
||||
if(m_proxyId != b2Pair.b2_nullProxy)
|
||||
{
|
||||
param1.DestroyProxy(m_proxyId);
|
||||
m_proxyId = b2Pair.b2_nullProxy;
|
||||
}
|
||||
}
|
||||
|
||||
public function Synchronize(param1:b2BroadPhase, param2:b2XForm, param3:b2XForm) : Boolean
|
||||
{
|
||||
if(m_proxyId == b2Pair.b2_nullProxy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var _loc4_:b2AABB = s_syncAABB;
|
||||
ComputeSweptAABB(_loc4_,param2,param3);
|
||||
if(param1.InRange(_loc4_))
|
||||
{
|
||||
param1.MoveProxy(m_proxyId,_loc4_);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function RefilterProxy(param1:b2BroadPhase, param2:b2XForm) : void
|
||||
{
|
||||
if(m_proxyId == b2Pair.b2_nullProxy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
param1.DestroyProxy(m_proxyId);
|
||||
var _loc4_:b2AABB = s_resetAABB;
|
||||
ComputeAABB(_loc4_,param2);
|
||||
var _loc3_:Boolean = param1.InRange(_loc4_);
|
||||
if(_loc3_)
|
||||
{
|
||||
m_proxyId = param1.CreateProxy(_loc4_,this);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_proxyId = b2Pair.b2_nullProxy;
|
||||
}
|
||||
}
|
||||
|
||||
public function UpdateSweepRadius(param1:b2Vec2) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package Box2D.Collision.Shapes
|
||||
{
|
||||
public class b2ShapeDef
|
||||
{
|
||||
|
||||
public var type:int = -1;
|
||||
|
||||
public var userData:* = null;
|
||||
|
||||
public var friction:Number = 0.2;
|
||||
|
||||
public var restitution:Number = 0;
|
||||
|
||||
public var density:Number = 0;
|
||||
|
||||
public var isSensor:Boolean = false;
|
||||
|
||||
public var filter:b2FilterData = new b2FilterData();
|
||||
|
||||
public function b2ShapeDef()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2AABB
|
||||
{
|
||||
|
||||
public var lowerBound:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var upperBound:b2Vec2 = new b2Vec2();
|
||||
|
||||
public function b2AABB()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function IsValid() : Boolean
|
||||
{
|
||||
var _loc2_:Number = upperBound.x - lowerBound.x;
|
||||
var _loc3_:Number = upperBound.y - lowerBound.y;
|
||||
var _loc1_:Boolean = _loc2_ >= 0 && _loc3_ >= 0;
|
||||
return _loc1_ && lowerBound.IsValid() && upperBound.IsValid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
public class b2Bound
|
||||
{
|
||||
|
||||
public var value:uint;
|
||||
|
||||
public var proxyId:uint;
|
||||
|
||||
public var stabbingCount:uint;
|
||||
|
||||
public function b2Bound()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function IsLower() : Boolean
|
||||
{
|
||||
return (value & 1) == 0;
|
||||
}
|
||||
|
||||
public function IsUpper() : Boolean
|
||||
{
|
||||
return (value & 1) == 1;
|
||||
}
|
||||
|
||||
public function Swap(param1:b2Bound) : void
|
||||
{
|
||||
var _loc4_:uint = value;
|
||||
var _loc3_:uint = proxyId;
|
||||
var _loc2_:uint = stabbingCount;
|
||||
value = param1.value;
|
||||
proxyId = param1.proxyId;
|
||||
stabbingCount = param1.stabbingCount;
|
||||
param1.value = _loc4_;
|
||||
param1.proxyId = _loc3_;
|
||||
param1.stabbingCount = _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
public class b2BoundValues
|
||||
{
|
||||
|
||||
public var lowerValues:Array = [0,0];
|
||||
|
||||
public var upperValues:Array = [0,0];
|
||||
|
||||
public function b2BoundValues()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,836 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
|
||||
public class b2BroadPhase
|
||||
{
|
||||
|
||||
public static var s_validate:Boolean = false;
|
||||
|
||||
public static const b2_invalid:uint = 65535;
|
||||
|
||||
public static const b2_nullEdge:uint = 65535;
|
||||
|
||||
public var m_pairManager:b2PairManager = new b2PairManager();
|
||||
|
||||
public var m_proxyPool:Array = new Array(4096);
|
||||
|
||||
public var m_freeProxy:uint;
|
||||
|
||||
public var m_bounds:Array = new Array(2 * 512);
|
||||
|
||||
public var m_queryResults:Array = new Array(512);
|
||||
|
||||
public var m_queryResultCount:int;
|
||||
|
||||
public var m_worldAABB:b2AABB;
|
||||
|
||||
public var m_quantizationFactor:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_proxyCount:int;
|
||||
|
||||
public var m_timeStamp:uint;
|
||||
|
||||
public function b2BroadPhase(param1:b2AABB, param2:b2PairCallback)
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc5_:b2Proxy = null;
|
||||
super();
|
||||
m_pairManager.Initialize(this,param2);
|
||||
m_worldAABB = param1;
|
||||
m_proxyCount = 0;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 512)
|
||||
{
|
||||
m_queryResults[_loc6_] = 0;
|
||||
_loc6_++;
|
||||
}
|
||||
m_bounds = new Array(2);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 2)
|
||||
{
|
||||
m_bounds[_loc6_] = new Array(2 * 512);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < 2 * 512)
|
||||
{
|
||||
m_bounds[_loc6_][_loc7_] = new b2Bound();
|
||||
_loc7_++;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
var _loc3_:Number = param1.upperBound.x - param1.lowerBound.x;
|
||||
var _loc4_:Number = param1.upperBound.y - param1.lowerBound.y;
|
||||
m_quantizationFactor.x = 65535 / _loc3_;
|
||||
m_quantizationFactor.y = 65535 / _loc4_;
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < 512 - 1)
|
||||
{
|
||||
_loc5_ = new b2Proxy();
|
||||
m_proxyPool[_loc6_] = _loc5_;
|
||||
_loc5_.SetNext(_loc6_ + 1);
|
||||
_loc5_.timeStamp = 0;
|
||||
_loc5_.overlapCount = 65535;
|
||||
_loc5_.userData = null;
|
||||
_loc6_++;
|
||||
}
|
||||
_loc5_ = new b2Proxy();
|
||||
m_proxyPool[511] = _loc5_;
|
||||
_loc5_.SetNext(b2Pair.b2_nullProxy);
|
||||
_loc5_.timeStamp = 0;
|
||||
_loc5_.overlapCount = 65535;
|
||||
_loc5_.userData = null;
|
||||
m_freeProxy = 0;
|
||||
m_timeStamp = 1;
|
||||
m_queryResultCount = 0;
|
||||
}
|
||||
|
||||
public static function BinarySearch(param1:Array, param2:int, param3:uint) : uint
|
||||
{
|
||||
var _loc7_:int = 0;
|
||||
var _loc6_:b2Bound = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:int = param2 - 1;
|
||||
while(_loc5_ <= _loc4_)
|
||||
{
|
||||
_loc7_ = (_loc5_ + _loc4_) / 2;
|
||||
_loc6_ = param1[_loc7_];
|
||||
if(_loc6_.value > param3)
|
||||
{
|
||||
_loc4_ = _loc7_ - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc6_.value >= param3)
|
||||
{
|
||||
return uint(_loc7_);
|
||||
}
|
||||
_loc5_ = _loc7_ + 1;
|
||||
}
|
||||
}
|
||||
return uint(_loc5_);
|
||||
}
|
||||
|
||||
public function InRange(param1:b2AABB) : Boolean
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
_loc2_ = param1.lowerBound.x;
|
||||
_loc3_ = param1.lowerBound.y;
|
||||
_loc2_ -= m_worldAABB.upperBound.x;
|
||||
_loc3_ -= m_worldAABB.upperBound.y;
|
||||
_loc5_ = m_worldAABB.lowerBound.x;
|
||||
_loc4_ = m_worldAABB.lowerBound.y;
|
||||
_loc5_ -= param1.upperBound.x;
|
||||
_loc4_ -= param1.upperBound.y;
|
||||
_loc2_ = b2Math.b2Max(_loc2_,_loc5_);
|
||||
_loc3_ = b2Math.b2Max(_loc3_,_loc4_);
|
||||
return b2Math.b2Max(_loc2_,_loc3_) < 0;
|
||||
}
|
||||
|
||||
public function GetProxy(param1:int) : b2Proxy
|
||||
{
|
||||
var _loc2_:b2Proxy = m_proxyPool[param1];
|
||||
if(param1 == b2Pair.b2_nullProxy || _loc2_.IsValid() == false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function CreateProxy(param1:b2AABB, param2:*) : uint
|
||||
{
|
||||
var _loc5_:* = 0;
|
||||
var _loc13_:b2Proxy = null;
|
||||
var _loc10_:int = 0;
|
||||
var _loc18_:Array = null;
|
||||
var _loc19_:* = 0;
|
||||
var _loc8_:* = 0;
|
||||
var _loc4_:Array = null;
|
||||
var _loc15_:Array = null;
|
||||
var _loc20_:Array = null;
|
||||
var _loc9_:int = 0;
|
||||
var _loc14_:int = 0;
|
||||
var _loc3_:b2Bound = null;
|
||||
var _loc11_:b2Bound = null;
|
||||
var _loc12_:b2Bound = null;
|
||||
var _loc16_:int = 0;
|
||||
var _loc22_:b2Proxy = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc23_:uint = m_freeProxy;
|
||||
_loc13_ = m_proxyPool[_loc23_];
|
||||
m_freeProxy = _loc13_.GetNext();
|
||||
_loc13_.overlapCount = 0;
|
||||
_loc13_.userData = param2;
|
||||
var _loc17_:uint = 2 * m_proxyCount;
|
||||
var _loc6_:Array = [];
|
||||
var _loc21_:Array = [];
|
||||
ComputeBounds(_loc6_,_loc21_,param1);
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < 2)
|
||||
{
|
||||
_loc18_ = m_bounds[_loc10_];
|
||||
_loc4_ = [_loc19_];
|
||||
_loc15_ = [_loc8_];
|
||||
Query(_loc4_,_loc15_,_loc6_[_loc10_],_loc21_[_loc10_],_loc18_,_loc17_,_loc10_);
|
||||
_loc19_ = uint(_loc4_[0]);
|
||||
_loc8_ = uint(_loc15_[0]);
|
||||
_loc20_ = [];
|
||||
_loc14_ = _loc17_ - _loc8_;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc14_)
|
||||
{
|
||||
_loc20_[_loc9_] = new b2Bound();
|
||||
_loc3_ = _loc20_[_loc9_];
|
||||
_loc11_ = _loc18_[int(_loc8_ + _loc9_)];
|
||||
_loc3_.value = _loc11_.value;
|
||||
_loc3_.proxyId = _loc11_.proxyId;
|
||||
_loc3_.stabbingCount = _loc11_.stabbingCount;
|
||||
_loc9_++;
|
||||
}
|
||||
_loc14_ = int(_loc20_.length);
|
||||
_loc16_ = _loc8_ + 2;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc14_)
|
||||
{
|
||||
_loc11_ = _loc20_[_loc9_];
|
||||
_loc3_ = _loc18_[int(_loc16_ + _loc9_)];
|
||||
_loc3_.value = _loc11_.value;
|
||||
_loc3_.proxyId = _loc11_.proxyId;
|
||||
_loc3_.stabbingCount = _loc11_.stabbingCount;
|
||||
_loc9_++;
|
||||
}
|
||||
_loc20_ = [];
|
||||
_loc14_ = _loc8_ - _loc19_;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc14_)
|
||||
{
|
||||
_loc20_[_loc9_] = new b2Bound();
|
||||
_loc3_ = _loc20_[_loc9_];
|
||||
_loc11_ = _loc18_[int(_loc19_ + _loc9_)];
|
||||
_loc3_.value = _loc11_.value;
|
||||
_loc3_.proxyId = _loc11_.proxyId;
|
||||
_loc3_.stabbingCount = _loc11_.stabbingCount;
|
||||
_loc9_++;
|
||||
}
|
||||
_loc14_ = int(_loc20_.length);
|
||||
_loc16_ = _loc19_ + 1;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc14_)
|
||||
{
|
||||
_loc11_ = _loc20_[_loc9_];
|
||||
_loc3_ = _loc18_[int(_loc16_ + _loc9_)];
|
||||
_loc3_.value = _loc11_.value;
|
||||
_loc3_.proxyId = _loc11_.proxyId;
|
||||
_loc3_.stabbingCount = _loc11_.stabbingCount;
|
||||
_loc9_++;
|
||||
}
|
||||
_loc8_++;
|
||||
_loc3_ = _loc18_[_loc19_];
|
||||
_loc11_ = _loc18_[_loc8_];
|
||||
_loc3_.value = _loc6_[_loc10_];
|
||||
_loc3_.proxyId = _loc23_;
|
||||
_loc11_.value = _loc21_[_loc10_];
|
||||
_loc11_.proxyId = _loc23_;
|
||||
_loc12_ = _loc18_[int(_loc19_ - 1)];
|
||||
_loc3_.stabbingCount = _loc19_ == 0 ? 0 : _loc12_.stabbingCount;
|
||||
_loc12_ = _loc18_[int(_loc8_ - 1)];
|
||||
_loc11_.stabbingCount = _loc12_.stabbingCount;
|
||||
_loc5_ = _loc19_;
|
||||
while(_loc5_ < _loc8_)
|
||||
{
|
||||
_loc12_ = _loc18_[_loc5_];
|
||||
_loc12_.stabbingCount++;
|
||||
_loc5_++;
|
||||
}
|
||||
_loc5_ = _loc19_;
|
||||
while(_loc5_ < _loc17_ + 2)
|
||||
{
|
||||
_loc3_ = _loc18_[_loc5_];
|
||||
_loc22_ = m_proxyPool[_loc3_.proxyId];
|
||||
if(_loc3_.IsLower())
|
||||
{
|
||||
_loc22_.lowerBounds[_loc10_] = _loc5_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc22_.upperBounds[_loc10_] = _loc5_;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
_loc10_++;
|
||||
}
|
||||
m_proxyCount = m_proxyCount + 1;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_queryResultCount)
|
||||
{
|
||||
m_pairManager.AddBufferedPair(_loc23_,m_queryResults[_loc7_]);
|
||||
_loc7_++;
|
||||
}
|
||||
m_pairManager.Commit();
|
||||
m_queryResultCount = 0;
|
||||
IncrementTimeStamp();
|
||||
return _loc23_;
|
||||
}
|
||||
|
||||
public function DestroyProxy(param1:uint) : void
|
||||
{
|
||||
var _loc2_:b2Bound = null;
|
||||
var _loc11_:b2Bound = null;
|
||||
var _loc10_:int = 0;
|
||||
var _loc16_:Array = null;
|
||||
var _loc17_:* = 0;
|
||||
var _loc7_:* = 0;
|
||||
var _loc9_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc18_:Array = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc13_:int = 0;
|
||||
var _loc14_:int = 0;
|
||||
var _loc4_:* = 0;
|
||||
var _loc19_:b2Proxy = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc12_:b2Proxy = m_proxyPool[param1];
|
||||
var _loc15_:int = 2 * m_proxyCount;
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < 2)
|
||||
{
|
||||
_loc16_ = m_bounds[_loc10_];
|
||||
_loc17_ = uint(_loc12_.lowerBounds[_loc10_]);
|
||||
_loc7_ = uint(_loc12_.upperBounds[_loc10_]);
|
||||
_loc2_ = _loc16_[_loc17_];
|
||||
_loc9_ = _loc2_.value;
|
||||
_loc11_ = _loc16_[_loc7_];
|
||||
_loc3_ = _loc11_.value;
|
||||
_loc18_ = [];
|
||||
_loc13_ = _loc7_ - _loc17_ - 1;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc13_)
|
||||
{
|
||||
_loc18_[_loc8_] = new b2Bound();
|
||||
_loc2_ = _loc18_[_loc8_];
|
||||
_loc11_ = _loc16_[int(_loc17_ + 1 + _loc8_)];
|
||||
_loc2_.value = _loc11_.value;
|
||||
_loc2_.proxyId = _loc11_.proxyId;
|
||||
_loc2_.stabbingCount = _loc11_.stabbingCount;
|
||||
_loc8_++;
|
||||
}
|
||||
_loc13_ = int(_loc18_.length);
|
||||
_loc14_ = _loc17_;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc13_)
|
||||
{
|
||||
_loc11_ = _loc18_[_loc8_];
|
||||
_loc2_ = _loc16_[int(_loc14_ + _loc8_)];
|
||||
_loc2_.value = _loc11_.value;
|
||||
_loc2_.proxyId = _loc11_.proxyId;
|
||||
_loc2_.stabbingCount = _loc11_.stabbingCount;
|
||||
_loc8_++;
|
||||
}
|
||||
_loc18_ = [];
|
||||
_loc13_ = _loc15_ - _loc7_ - 1;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc13_)
|
||||
{
|
||||
_loc18_[_loc8_] = new b2Bound();
|
||||
_loc2_ = _loc18_[_loc8_];
|
||||
_loc11_ = _loc16_[int(_loc7_ + 1 + _loc8_)];
|
||||
_loc2_.value = _loc11_.value;
|
||||
_loc2_.proxyId = _loc11_.proxyId;
|
||||
_loc2_.stabbingCount = _loc11_.stabbingCount;
|
||||
_loc8_++;
|
||||
}
|
||||
_loc13_ = int(_loc18_.length);
|
||||
_loc14_ = _loc7_ - 1;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc13_)
|
||||
{
|
||||
_loc11_ = _loc18_[_loc8_];
|
||||
_loc2_ = _loc16_[int(_loc14_ + _loc8_)];
|
||||
_loc2_.value = _loc11_.value;
|
||||
_loc2_.proxyId = _loc11_.proxyId;
|
||||
_loc2_.stabbingCount = _loc11_.stabbingCount;
|
||||
_loc8_++;
|
||||
}
|
||||
_loc13_ = _loc15_ - 2;
|
||||
_loc4_ = _loc17_;
|
||||
while(_loc4_ < _loc13_)
|
||||
{
|
||||
_loc2_ = _loc16_[_loc4_];
|
||||
_loc19_ = m_proxyPool[_loc2_.proxyId];
|
||||
if(_loc2_.IsLower())
|
||||
{
|
||||
_loc19_.lowerBounds[_loc10_] = _loc4_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc19_.upperBounds[_loc10_] = _loc4_;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
_loc13_ = _loc7_ - 1;
|
||||
_loc5_ = _loc17_;
|
||||
while(_loc5_ < _loc13_)
|
||||
{
|
||||
_loc2_ = _loc16_[_loc5_];
|
||||
_loc2_.stabbingCount--;
|
||||
_loc5_++;
|
||||
}
|
||||
Query([0],[0],_loc9_,_loc3_,_loc16_,_loc15_ - 2,_loc10_);
|
||||
_loc10_++;
|
||||
}
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < m_queryResultCount)
|
||||
{
|
||||
m_pairManager.RemoveBufferedPair(param1,m_queryResults[_loc6_]);
|
||||
_loc6_++;
|
||||
}
|
||||
m_pairManager.Commit();
|
||||
m_queryResultCount = 0;
|
||||
IncrementTimeStamp();
|
||||
_loc12_.userData = null;
|
||||
_loc12_.overlapCount = 65535;
|
||||
_loc12_.lowerBounds[0] = 65535;
|
||||
_loc12_.lowerBounds[1] = 65535;
|
||||
_loc12_.upperBounds[0] = 65535;
|
||||
_loc12_.upperBounds[1] = 65535;
|
||||
_loc12_.SetNext(m_freeProxy);
|
||||
m_freeProxy = param1;
|
||||
m_proxyCount = m_proxyCount - 1;
|
||||
}
|
||||
|
||||
public function MoveProxy(param1:uint, param2:b2AABB) : void
|
||||
{
|
||||
var _loc16_:Array = null;
|
||||
var _loc23_:int = 0;
|
||||
var _loc12_:* = 0;
|
||||
var _loc8_:* = 0;
|
||||
var _loc7_:b2Bound = null;
|
||||
var _loc17_:b2Bound = null;
|
||||
var _loc21_:b2Bound = null;
|
||||
var _loc22_:* = 0;
|
||||
var _loc4_:b2Proxy = null;
|
||||
var _loc19_:Array = null;
|
||||
var _loc20_:* = 0;
|
||||
var _loc9_:* = 0;
|
||||
var _loc11_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc10_:* = 0;
|
||||
var _loc24_:b2Proxy = null;
|
||||
if(param1 == b2Pair.b2_nullProxy || 512 <= param1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(param2.IsValid() == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc18_:uint = 2 * m_proxyCount;
|
||||
var _loc15_:b2Proxy = m_proxyPool[param1];
|
||||
var _loc13_:b2BoundValues = new b2BoundValues();
|
||||
ComputeBounds(_loc13_.lowerValues,_loc13_.upperValues,param2);
|
||||
var _loc14_:b2BoundValues = new b2BoundValues();
|
||||
_loc12_ = 0;
|
||||
while(_loc12_ < 2)
|
||||
{
|
||||
_loc7_ = m_bounds[_loc12_][_loc15_.lowerBounds[_loc12_]];
|
||||
_loc14_.lowerValues[_loc12_] = _loc7_.value;
|
||||
_loc7_ = m_bounds[_loc12_][_loc15_.upperBounds[_loc12_]];
|
||||
_loc14_.upperValues[_loc12_] = _loc7_.value;
|
||||
_loc12_++;
|
||||
}
|
||||
_loc12_ = 0;
|
||||
while(_loc12_ < 2)
|
||||
{
|
||||
_loc19_ = m_bounds[_loc12_];
|
||||
_loc20_ = uint(_loc15_.lowerBounds[_loc12_]);
|
||||
_loc9_ = uint(_loc15_.upperBounds[_loc12_]);
|
||||
_loc11_ = uint(_loc13_.lowerValues[_loc12_]);
|
||||
_loc6_ = uint(_loc13_.upperValues[_loc12_]);
|
||||
_loc7_ = _loc19_[_loc20_];
|
||||
_loc5_ = _loc11_ - _loc7_.value;
|
||||
_loc7_.value = _loc11_;
|
||||
_loc7_ = _loc19_[_loc9_];
|
||||
_loc3_ = _loc6_ - _loc7_.value;
|
||||
_loc7_.value = _loc6_;
|
||||
if(_loc5_ < 0)
|
||||
{
|
||||
_loc8_ = _loc20_;
|
||||
while(_loc8_ > 0 && _loc11_ < (_loc19_[int(_loc8_ - 1)] as b2Bound).value)
|
||||
{
|
||||
_loc7_ = _loc19_[_loc8_];
|
||||
_loc17_ = _loc19_[int(_loc8_ - 1)];
|
||||
_loc10_ = _loc17_.proxyId;
|
||||
_loc24_ = m_proxyPool[_loc17_.proxyId];
|
||||
_loc17_.stabbingCount++;
|
||||
if(_loc17_.IsUpper() == true)
|
||||
{
|
||||
if(TestOverlap(_loc13_,_loc24_))
|
||||
{
|
||||
m_pairManager.AddBufferedPair(param1,_loc10_);
|
||||
}
|
||||
_loc16_ = _loc24_.upperBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_++;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.stabbingCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc16_ = _loc24_.lowerBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_++;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.stabbingCount--;
|
||||
}
|
||||
_loc16_ = _loc15_.lowerBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_--;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.Swap(_loc17_);
|
||||
_loc8_--;
|
||||
}
|
||||
}
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
_loc8_ = _loc9_;
|
||||
while(_loc8_ < _loc18_ - 1 && (_loc19_[int(_loc8_ + 1)] as b2Bound).value <= _loc6_)
|
||||
{
|
||||
_loc7_ = _loc19_[_loc8_];
|
||||
_loc21_ = _loc19_[int(_loc8_ + 1)];
|
||||
_loc22_ = _loc21_.proxyId;
|
||||
_loc4_ = m_proxyPool[_loc22_];
|
||||
_loc21_.stabbingCount++;
|
||||
if(_loc21_.IsLower() == true)
|
||||
{
|
||||
if(TestOverlap(_loc13_,_loc4_))
|
||||
{
|
||||
m_pairManager.AddBufferedPair(param1,_loc22_);
|
||||
}
|
||||
_loc16_ = _loc4_.lowerBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_--;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.stabbingCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc16_ = _loc4_.upperBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_--;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.stabbingCount--;
|
||||
}
|
||||
_loc16_ = _loc15_.upperBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_++;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.Swap(_loc21_);
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
if(_loc5_ > 0)
|
||||
{
|
||||
_loc8_ = _loc20_;
|
||||
while(_loc8_ < _loc18_ - 1 && (_loc19_[int(_loc8_ + 1)] as b2Bound).value <= _loc11_)
|
||||
{
|
||||
_loc7_ = _loc19_[_loc8_];
|
||||
_loc21_ = _loc19_[int(_loc8_ + 1)];
|
||||
_loc22_ = _loc21_.proxyId;
|
||||
_loc4_ = m_proxyPool[_loc22_];
|
||||
_loc21_.stabbingCount--;
|
||||
if(_loc21_.IsUpper())
|
||||
{
|
||||
if(TestOverlap(_loc14_,_loc4_))
|
||||
{
|
||||
m_pairManager.RemoveBufferedPair(param1,_loc22_);
|
||||
}
|
||||
_loc16_ = _loc4_.upperBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_--;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.stabbingCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc16_ = _loc4_.lowerBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_--;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.stabbingCount++;
|
||||
}
|
||||
_loc16_ = _loc15_.lowerBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_++;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.Swap(_loc21_);
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
if(_loc3_ < 0)
|
||||
{
|
||||
_loc8_ = _loc9_;
|
||||
while(_loc8_ > 0 && _loc6_ < (_loc19_[int(_loc8_ - 1)] as b2Bound).value)
|
||||
{
|
||||
_loc7_ = _loc19_[_loc8_];
|
||||
_loc17_ = _loc19_[int(_loc8_ - 1)];
|
||||
_loc10_ = _loc17_.proxyId;
|
||||
_loc24_ = m_proxyPool[_loc10_];
|
||||
_loc17_.stabbingCount--;
|
||||
if(_loc17_.IsLower() == true)
|
||||
{
|
||||
if(TestOverlap(_loc14_,_loc24_))
|
||||
{
|
||||
m_pairManager.RemoveBufferedPair(param1,_loc10_);
|
||||
}
|
||||
_loc16_ = _loc24_.lowerBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_++;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.stabbingCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc16_ = _loc24_.upperBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_++;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.stabbingCount++;
|
||||
}
|
||||
_loc16_ = _loc15_.upperBounds;
|
||||
_loc23_ = int(_loc16_[_loc12_]);
|
||||
_loc23_--;
|
||||
_loc16_[_loc12_] = _loc23_;
|
||||
_loc7_.Swap(_loc17_);
|
||||
_loc8_--;
|
||||
}
|
||||
}
|
||||
_loc12_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function Commit() : void
|
||||
{
|
||||
m_pairManager.Commit();
|
||||
}
|
||||
|
||||
public function QueryAABB(param1:b2AABB, param2:*, param3:int) : int
|
||||
{
|
||||
var _loc7_:int = 0;
|
||||
var _loc11_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc4_:b2Proxy = null;
|
||||
var _loc9_:Array = [];
|
||||
var _loc12_:Array = [];
|
||||
ComputeBounds(_loc9_,_loc12_,param1);
|
||||
var _loc5_:Array = [_loc7_];
|
||||
var _loc6_:Array = [_loc11_];
|
||||
Query(_loc5_,_loc6_,_loc9_[0],_loc12_[0],m_bounds[0],2 * m_proxyCount,0);
|
||||
Query(_loc5_,_loc6_,_loc9_[1],_loc12_[1],m_bounds[1],2 * m_proxyCount,1);
|
||||
var _loc8_:int = 0;
|
||||
_loc10_ = 0;
|
||||
while(_loc10_ < m_queryResultCount && _loc8_ < param3)
|
||||
{
|
||||
_loc4_ = m_proxyPool[m_queryResults[_loc10_]];
|
||||
param2[_loc10_] = _loc4_.userData;
|
||||
_loc10_++;
|
||||
++_loc8_;
|
||||
}
|
||||
m_queryResultCount = 0;
|
||||
IncrementTimeStamp();
|
||||
return _loc8_;
|
||||
}
|
||||
|
||||
public function Validate() : void
|
||||
{
|
||||
var _loc9_:* = null;
|
||||
var _loc6_:* = null;
|
||||
var _loc8_:* = null;
|
||||
var _loc1_:Boolean = false;
|
||||
var _loc7_:int = 0;
|
||||
var _loc3_:b2Bound = null;
|
||||
var _loc4_:* = 0;
|
||||
var _loc10_:* = 0;
|
||||
var _loc5_:* = 0;
|
||||
var _loc2_:b2Bound = null;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < 2)
|
||||
{
|
||||
_loc3_ = m_bounds[_loc7_];
|
||||
_loc4_ = uint(2 * m_proxyCount);
|
||||
_loc10_ = 0;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc4_)
|
||||
{
|
||||
_loc2_ = _loc3_[_loc5_];
|
||||
if(_loc2_.IsLower() == true)
|
||||
{
|
||||
_loc10_++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc10_--;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function ComputeBounds(param1:Array, param2:Array, param3:b2AABB) : void
|
||||
{
|
||||
var _loc4_:Number = param3.lowerBound.x;
|
||||
var _loc5_:Number = param3.lowerBound.y;
|
||||
_loc4_ = b2Math.b2Min(_loc4_,m_worldAABB.upperBound.x);
|
||||
_loc5_ = b2Math.b2Min(_loc5_,m_worldAABB.upperBound.y);
|
||||
_loc4_ = b2Math.b2Max(_loc4_,m_worldAABB.lowerBound.x);
|
||||
_loc5_ = b2Math.b2Max(_loc5_,m_worldAABB.lowerBound.y);
|
||||
var _loc6_:Number = param3.upperBound.x;
|
||||
var _loc7_:Number = param3.upperBound.y;
|
||||
_loc6_ = b2Math.b2Min(_loc6_,m_worldAABB.upperBound.x);
|
||||
_loc7_ = b2Math.b2Min(_loc7_,m_worldAABB.upperBound.y);
|
||||
_loc6_ = b2Math.b2Max(_loc6_,m_worldAABB.lowerBound.x);
|
||||
_loc7_ = b2Math.b2Max(_loc7_,m_worldAABB.lowerBound.y);
|
||||
param1[0] = uint(m_quantizationFactor.x * (_loc4_ - m_worldAABB.lowerBound.x)) & 65535 - 1;
|
||||
param2[0] = uint(m_quantizationFactor.x * (_loc6_ - m_worldAABB.lowerBound.x)) & 0xFFFF | 1;
|
||||
param1[1] = uint(m_quantizationFactor.y * (_loc5_ - m_worldAABB.lowerBound.y)) & 65535 - 1;
|
||||
param2[1] = uint(m_quantizationFactor.y * (_loc7_ - m_worldAABB.lowerBound.y)) & 0xFFFF | 1;
|
||||
}
|
||||
|
||||
private function TestOverlapValidate(param1:b2Proxy, param2:b2Proxy) : Boolean
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:Array = null;
|
||||
var _loc6_:b2Bound = null;
|
||||
var _loc4_:b2Bound = null;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 2)
|
||||
{
|
||||
_loc3_ = m_bounds[_loc5_];
|
||||
_loc6_ = _loc3_[param1.lowerBounds[_loc5_]];
|
||||
_loc4_ = _loc3_[param2.upperBounds[_loc5_]];
|
||||
if(_loc6_.value > _loc4_.value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc6_ = _loc3_[param1.upperBounds[_loc5_]];
|
||||
_loc4_ = _loc3_[param2.lowerBounds[_loc5_]];
|
||||
if(_loc6_.value < _loc4_.value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function TestOverlap(param1:b2BoundValues, param2:b2Proxy) : Boolean
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:Array = null;
|
||||
var _loc3_:b2Bound = null;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 2)
|
||||
{
|
||||
_loc4_ = m_bounds[_loc5_];
|
||||
_loc3_ = _loc4_[param2.upperBounds[_loc5_]];
|
||||
if(param1.lowerValues[_loc5_] > _loc3_.value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc3_ = _loc4_[param2.lowerBounds[_loc5_]];
|
||||
if(param1.upperValues[_loc5_] < _loc3_.value)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function Query(param1:Array, param2:Array, param3:uint, param4:uint, param5:Array, param6:uint, param7:int) : void
|
||||
{
|
||||
var _loc8_:b2Bound = null;
|
||||
var _loc11_:* = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc13_:int = 0;
|
||||
var _loc12_:b2Proxy = null;
|
||||
var _loc14_:uint = BinarySearch(param5,param6,param3);
|
||||
var _loc9_:uint = BinarySearch(param5,param6,param4);
|
||||
_loc11_ = _loc14_;
|
||||
while(_loc11_ < _loc9_)
|
||||
{
|
||||
_loc8_ = param5[_loc11_];
|
||||
if(_loc8_.IsLower())
|
||||
{
|
||||
IncrementOverlapCount(_loc8_.proxyId);
|
||||
}
|
||||
_loc11_++;
|
||||
}
|
||||
if(_loc14_ > 0)
|
||||
{
|
||||
_loc10_ = _loc14_ - 1;
|
||||
_loc8_ = param5[_loc10_];
|
||||
_loc13_ = int(_loc8_.stabbingCount);
|
||||
while(_loc13_)
|
||||
{
|
||||
_loc8_ = param5[_loc10_];
|
||||
if(_loc8_.IsLower())
|
||||
{
|
||||
_loc12_ = m_proxyPool[_loc8_.proxyId];
|
||||
if(_loc14_ <= _loc12_.upperBounds[param7])
|
||||
{
|
||||
IncrementOverlapCount(_loc8_.proxyId);
|
||||
_loc13_--;
|
||||
}
|
||||
}
|
||||
_loc10_--;
|
||||
}
|
||||
}
|
||||
param1[0] = _loc14_;
|
||||
param2[0] = _loc9_;
|
||||
}
|
||||
|
||||
private function IncrementOverlapCount(param1:uint) : void
|
||||
{
|
||||
var _loc2_:b2Proxy = m_proxyPool[param1];
|
||||
if(_loc2_.timeStamp < m_timeStamp)
|
||||
{
|
||||
_loc2_.timeStamp = m_timeStamp;
|
||||
_loc2_.overlapCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.overlapCount = 2;
|
||||
m_queryResults[m_queryResultCount] = param1;
|
||||
m_queryResultCount = m_queryResultCount + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private function IncrementTimeStamp() : void
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
if(m_timeStamp == 65535)
|
||||
{
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 512)
|
||||
{
|
||||
(m_proxyPool[_loc1_] as b2Proxy).timeStamp = 0;
|
||||
_loc1_++;
|
||||
}
|
||||
m_timeStamp = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_timeStamp = m_timeStamp + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
public class b2BufferedPair
|
||||
{
|
||||
|
||||
public var proxyId1:uint;
|
||||
|
||||
public var proxyId2:uint;
|
||||
|
||||
public function b2BufferedPair()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,590 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Collision.Shapes.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
|
||||
public class b2Collision
|
||||
{
|
||||
|
||||
public static const b2_nullFeature:uint = 255;
|
||||
|
||||
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
|
||||
|
||||
public function b2Collision()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function ClipSegmentToLine(param1:Array, param2:Array, param3:b2Vec2, param4:Number) : int
|
||||
{
|
||||
var _loc11_:ClipVertex = null;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc12_:b2Vec2 = null;
|
||||
var _loc13_:ClipVertex = null;
|
||||
var _loc10_:int = 0;
|
||||
_loc11_ = param2[0];
|
||||
var _loc6_:b2Vec2 = _loc11_.v;
|
||||
_loc11_ = param2[1];
|
||||
var _loc5_:b2Vec2 = _loc11_.v;
|
||||
var _loc8_:Number = b2Math.b2Dot(param3,_loc6_) - param4;
|
||||
var _loc7_:Number = b2Math.b2Dot(param3,_loc5_) - param4;
|
||||
if(_loc8_ <= 0)
|
||||
{
|
||||
param1[_loc10_++] = param2[0];
|
||||
}
|
||||
if(_loc7_ <= 0)
|
||||
{
|
||||
param1[_loc10_++] = param2[1];
|
||||
}
|
||||
if(_loc8_ * _loc7_ < 0)
|
||||
{
|
||||
_loc9_ = _loc8_ / (_loc8_ - _loc7_);
|
||||
_loc11_ = param1[_loc10_];
|
||||
_loc12_ = _loc11_.v;
|
||||
_loc12_.x = _loc6_.x + _loc9_ * (_loc5_.x - _loc6_.x);
|
||||
_loc12_.y = _loc6_.y + _loc9_ * (_loc5_.y - _loc6_.y);
|
||||
_loc11_ = param1[_loc10_];
|
||||
if(_loc8_ > 0)
|
||||
{
|
||||
_loc13_ = param2[0];
|
||||
_loc11_.id = _loc13_.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = param2[1];
|
||||
_loc11_.id = _loc13_.id;
|
||||
}
|
||||
_loc10_++;
|
||||
}
|
||||
return _loc10_;
|
||||
}
|
||||
|
||||
public static function EdgeSeparation(param1:b2PolygonShape, param2:b2XForm, param3:int, param4:b2PolygonShape, param5:b2XForm) : Number
|
||||
{
|
||||
var _loc23_:b2Mat22 = null;
|
||||
var _loc22_:b2Vec2 = null;
|
||||
var _loc20_:int = 0;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc6_:int = param1.m_vertexCount;
|
||||
var _loc8_:Array = param1.m_vertices;
|
||||
var _loc11_:Array = param1.m_normals;
|
||||
var _loc7_:int = param4.m_vertexCount;
|
||||
var _loc10_:Array = param4.m_vertices;
|
||||
_loc23_ = param2.R;
|
||||
_loc22_ = _loc11_[param3];
|
||||
var _loc17_:Number = _loc23_.col1.x * _loc22_.x + _loc23_.col2.x * _loc22_.y;
|
||||
var _loc15_:Number = _loc23_.col1.y * _loc22_.x + _loc23_.col2.y * _loc22_.y;
|
||||
_loc23_ = param5.R;
|
||||
var _loc18_:Number = _loc23_.col1.x * _loc17_ + _loc23_.col1.y * _loc15_;
|
||||
var _loc16_:Number = _loc23_.col2.x * _loc17_ + _loc23_.col2.y * _loc15_;
|
||||
var _loc19_:int = 0;
|
||||
var _loc21_:Number = 1.7976931348623157e+308;
|
||||
_loc20_ = 0;
|
||||
while(_loc20_ < _loc7_)
|
||||
{
|
||||
_loc22_ = _loc10_[_loc20_];
|
||||
_loc9_ = _loc22_.x * _loc18_ + _loc22_.y * _loc16_;
|
||||
if(_loc9_ < _loc21_)
|
||||
{
|
||||
_loc21_ = _loc9_;
|
||||
_loc19_ = _loc20_;
|
||||
}
|
||||
_loc20_++;
|
||||
}
|
||||
_loc22_ = _loc8_[param3];
|
||||
_loc23_ = param2.R;
|
||||
var _loc24_:Number = param2.position.x + (_loc23_.col1.x * _loc22_.x + _loc23_.col2.x * _loc22_.y);
|
||||
var _loc25_:Number = param2.position.y + (_loc23_.col1.y * _loc22_.x + _loc23_.col2.y * _loc22_.y);
|
||||
_loc22_ = _loc10_[_loc19_];
|
||||
_loc23_ = param5.R;
|
||||
var _loc14_:Number = param5.position.x + (_loc23_.col1.x * _loc22_.x + _loc23_.col2.x * _loc22_.y);
|
||||
var _loc13_:Number = param5.position.y + (_loc23_.col1.y * _loc22_.x + _loc23_.col2.y * _loc22_.y);
|
||||
_loc14_ -= _loc24_;
|
||||
_loc13_ -= _loc25_;
|
||||
return _loc14_ * _loc17_ + _loc13_ * _loc15_;
|
||||
}
|
||||
|
||||
public static function FindMaxSeparation(param1:Array, param2:b2PolygonShape, param3:b2XForm, param4:b2PolygonShape, param5:b2XForm) : Number
|
||||
{
|
||||
var _loc20_:b2Vec2 = null;
|
||||
var _loc23_:b2Mat22 = null;
|
||||
var _loc16_:int = 0;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:int = 0;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc9_:int = 0;
|
||||
var _loc6_:int = param2.m_vertexCount;
|
||||
var _loc11_:Array = param2.m_normals;
|
||||
_loc23_ = param5.R;
|
||||
_loc20_ = param4.m_centroid;
|
||||
var _loc18_:Number = param5.position.x + (_loc23_.col1.x * _loc20_.x + _loc23_.col2.x * _loc20_.y);
|
||||
var _loc19_:Number = param5.position.y + (_loc23_.col1.y * _loc20_.x + _loc23_.col2.y * _loc20_.y);
|
||||
_loc23_ = param3.R;
|
||||
_loc20_ = param2.m_centroid;
|
||||
_loc18_ -= param3.position.x + (_loc23_.col1.x * _loc20_.x + _loc23_.col2.x * _loc20_.y);
|
||||
_loc19_ -= param3.position.y + (_loc23_.col1.y * _loc20_.x + _loc23_.col2.y * _loc20_.y);
|
||||
var _loc22_:Number = _loc18_ * param3.R.col1.x + _loc19_ * param3.R.col1.y;
|
||||
var _loc21_:Number = _loc18_ * param3.R.col2.x + _loc19_ * param3.R.col2.y;
|
||||
var _loc13_:int = 0;
|
||||
var _loc10_:Number = -1.7976931348623157e+308;
|
||||
_loc16_ = 0;
|
||||
while(_loc16_ < _loc6_)
|
||||
{
|
||||
_loc20_ = _loc11_[_loc16_];
|
||||
_loc7_ = _loc20_.x * _loc22_ + _loc20_.y * _loc21_;
|
||||
if(_loc7_ > _loc10_)
|
||||
{
|
||||
_loc10_ = _loc7_;
|
||||
_loc13_ = _loc16_;
|
||||
}
|
||||
_loc16_++;
|
||||
}
|
||||
var _loc17_:Number = EdgeSeparation(param2,param3,_loc13_,param4,param5);
|
||||
if(_loc17_ > 0)
|
||||
{
|
||||
return _loc17_;
|
||||
}
|
||||
var _loc14_:int = _loc13_ - 1 >= 0 ? _loc13_ - 1 : _loc6_ - 1;
|
||||
var _loc24_:Number = EdgeSeparation(param2,param3,_loc14_,param4,param5);
|
||||
if(_loc24_ > 0)
|
||||
{
|
||||
return _loc24_;
|
||||
}
|
||||
var _loc12_:int = _loc13_ + 1 < _loc6_ ? _loc13_ + 1 : 0;
|
||||
var _loc25_:Number = EdgeSeparation(param2,param3,_loc12_,param4,param5);
|
||||
if(_loc25_ > 0)
|
||||
{
|
||||
return _loc25_;
|
||||
}
|
||||
if(_loc24_ > _loc17_ && _loc24_ > _loc25_)
|
||||
{
|
||||
_loc9_ = -1;
|
||||
_loc8_ = _loc14_;
|
||||
_loc15_ = _loc24_;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc25_ <= _loc17_)
|
||||
{
|
||||
param1[0] = _loc13_;
|
||||
return _loc17_;
|
||||
}
|
||||
_loc9_ = 1;
|
||||
_loc8_ = _loc12_;
|
||||
_loc15_ = _loc25_;
|
||||
}
|
||||
while(true)
|
||||
{
|
||||
if(_loc9_ == -1)
|
||||
{
|
||||
_loc13_ = _loc8_ - 1 >= 0 ? _loc8_ - 1 : _loc6_ - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc13_ = _loc8_ + 1 < _loc6_ ? _loc8_ + 1 : 0;
|
||||
}
|
||||
_loc17_ = EdgeSeparation(param2,param3,_loc13_,param4,param5);
|
||||
if(_loc17_ > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(_loc17_ <= _loc15_)
|
||||
{
|
||||
param1[0] = _loc8_;
|
||||
return _loc15_;
|
||||
}
|
||||
_loc8_ = _loc13_;
|
||||
_loc15_ = _loc17_;
|
||||
}
|
||||
return _loc17_;
|
||||
}
|
||||
|
||||
public static function FindIncidentEdge(param1:Array, param2:b2PolygonShape, param3:b2XForm, param4:int, param5:b2PolygonShape, param6:b2XForm) : void
|
||||
{
|
||||
var _loc23_:b2Mat22 = null;
|
||||
var _loc22_:b2Vec2 = null;
|
||||
var _loc17_:int = 0;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc12_:ClipVertex = null;
|
||||
var _loc7_:int = param2.m_vertexCount;
|
||||
var _loc21_:Array = param2.m_normals;
|
||||
var _loc8_:int = param5.m_vertexCount;
|
||||
var _loc15_:Array = param5.m_vertices;
|
||||
var _loc19_:Array = param5.m_normals;
|
||||
_loc23_ = param3.R;
|
||||
_loc22_ = _loc21_[param4];
|
||||
var _loc11_:Number = _loc23_.col1.x * _loc22_.x + _loc23_.col2.x * _loc22_.y;
|
||||
var _loc9_:Number = _loc23_.col1.y * _loc22_.x + _loc23_.col2.y * _loc22_.y;
|
||||
_loc23_ = param6.R;
|
||||
var _loc10_:Number = _loc23_.col1.x * _loc11_ + _loc23_.col1.y * _loc9_;
|
||||
_loc9_ = _loc23_.col2.x * _loc11_ + _loc23_.col2.y * _loc9_;
|
||||
_loc11_ = _loc10_;
|
||||
var _loc16_:int = 0;
|
||||
var _loc20_:Number = 1.7976931348623157e+308;
|
||||
_loc17_ = 0;
|
||||
while(_loc17_ < _loc8_)
|
||||
{
|
||||
_loc22_ = _loc19_[_loc17_];
|
||||
_loc13_ = _loc11_ * _loc22_.x + _loc9_ * _loc22_.y;
|
||||
if(_loc13_ < _loc20_)
|
||||
{
|
||||
_loc20_ = _loc13_;
|
||||
_loc16_ = _loc17_;
|
||||
}
|
||||
_loc17_++;
|
||||
}
|
||||
var _loc14_:int = _loc16_;
|
||||
var _loc18_:int = _loc14_ + 1 < _loc8_ ? _loc14_ + 1 : 0;
|
||||
_loc12_ = param1[0];
|
||||
_loc22_ = _loc15_[_loc14_];
|
||||
_loc23_ = param6.R;
|
||||
_loc12_.v.x = param6.position.x + (_loc23_.col1.x * _loc22_.x + _loc23_.col2.x * _loc22_.y);
|
||||
_loc12_.v.y = param6.position.y + (_loc23_.col1.y * _loc22_.x + _loc23_.col2.y * _loc22_.y);
|
||||
_loc12_.id.features.referenceEdge = param4;
|
||||
_loc12_.id.features.incidentEdge = _loc14_;
|
||||
_loc12_.id.features.incidentVertex = 0;
|
||||
_loc12_ = param1[1];
|
||||
_loc22_ = _loc15_[_loc18_];
|
||||
_loc23_ = param6.R;
|
||||
_loc12_.v.x = param6.position.x + (_loc23_.col1.x * _loc22_.x + _loc23_.col2.x * _loc22_.y);
|
||||
_loc12_.v.y = param6.position.y + (_loc23_.col1.y * _loc22_.x + _loc23_.col2.y * _loc22_.y);
|
||||
_loc12_.id.features.referenceEdge = param4;
|
||||
_loc12_.id.features.incidentEdge = _loc18_;
|
||||
_loc12_.id.features.incidentVertex = 1;
|
||||
}
|
||||
|
||||
public static function b2CollidePolygons(param1:b2Manifold, param2:b2PolygonShape, param3:b2XForm, param4:b2PolygonShape, param5:b2XForm) : void
|
||||
{
|
||||
var _loc34_:ClipVertex = null;
|
||||
var _loc38_:b2PolygonShape = null;
|
||||
var _loc37_:b2PolygonShape = null;
|
||||
var _loc29_:int = 0;
|
||||
var _loc21_:* = 0;
|
||||
var _loc12_:Number = NaN;
|
||||
_loc12_ = 0.98;
|
||||
var _loc27_:Number = NaN;
|
||||
_loc27_ = 0.001;
|
||||
var _loc16_:b2Vec2 = null;
|
||||
var _loc9_:int = 0;
|
||||
var _loc28_:int = 0;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc31_:b2ManifoldPoint = null;
|
||||
param1.pointCount = 0;
|
||||
var _loc18_:int = 0;
|
||||
var _loc22_:Array = [_loc18_];
|
||||
var _loc23_:Number = FindMaxSeparation(_loc22_,param2,param3,param4,param5);
|
||||
_loc18_ = int(_loc22_[0]);
|
||||
if(_loc23_ > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc19_:int = 0;
|
||||
var _loc6_:Array = [_loc19_];
|
||||
var _loc24_:Number = FindMaxSeparation(_loc6_,param4,param5,param2,param3);
|
||||
_loc19_ = int(_loc6_[0]);
|
||||
if(_loc24_ > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc8_:b2XForm = new b2XForm();
|
||||
var _loc10_:b2XForm = new b2XForm();
|
||||
if(_loc24_ > 0.98 * _loc23_ + 0.001)
|
||||
{
|
||||
_loc38_ = param4;
|
||||
_loc37_ = param2;
|
||||
_loc8_.Set(param5);
|
||||
_loc10_.Set(param3);
|
||||
_loc29_ = _loc19_;
|
||||
_loc21_ = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc38_ = param2;
|
||||
_loc37_ = param4;
|
||||
_loc8_.Set(param3);
|
||||
_loc10_.Set(param5);
|
||||
_loc29_ = _loc18_;
|
||||
_loc21_ = 0;
|
||||
}
|
||||
var _loc32_:Array = [new ClipVertex(),new ClipVertex()];
|
||||
FindIncidentEdge(_loc32_,_loc38_,_loc8_,_loc29_,_loc37_,_loc10_);
|
||||
var _loc7_:int = _loc38_.m_vertexCount;
|
||||
var _loc11_:Array = _loc38_.m_vertices;
|
||||
var _loc36_:b2Vec2 = _loc11_[_loc29_];
|
||||
var _loc17_:b2Vec2 = _loc36_.Copy();
|
||||
if(_loc29_ + 1 < _loc7_)
|
||||
{
|
||||
_loc36_ = _loc11_[int(_loc29_ + 1)];
|
||||
_loc16_ = _loc36_.Copy();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc36_ = _loc11_[0];
|
||||
_loc16_ = _loc36_.Copy();
|
||||
}
|
||||
var _loc14_:b2Vec2 = b2Math.SubtractVV(_loc16_,_loc17_);
|
||||
var _loc20_:b2Vec2 = b2Math.b2MulMV(_loc8_.R,b2Math.SubtractVV(_loc16_,_loc17_));
|
||||
_loc20_.Normalize();
|
||||
var _loc13_:b2Vec2 = b2Math.b2CrossVF(_loc20_,1);
|
||||
_loc17_ = b2Math.b2MulX(_loc8_,_loc17_);
|
||||
_loc16_ = b2Math.b2MulX(_loc8_,_loc16_);
|
||||
var _loc30_:Number = b2Math.b2Dot(_loc13_,_loc17_);
|
||||
var _loc39_:Number = -b2Math.b2Dot(_loc20_,_loc17_);
|
||||
var _loc35_:Number = b2Math.b2Dot(_loc20_,_loc16_);
|
||||
var _loc26_:Array = [new ClipVertex(),new ClipVertex()];
|
||||
var _loc25_:Array = [new ClipVertex(),new ClipVertex()];
|
||||
_loc9_ = ClipSegmentToLine(_loc26_,_loc32_,_loc20_.Negative(),_loc39_);
|
||||
if(_loc9_ < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_loc9_ = ClipSegmentToLine(_loc25_,_loc26_,_loc20_,_loc35_);
|
||||
if(_loc9_ < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
param1.normal = _loc21_ ? _loc13_.Negative() : _loc13_.Copy();
|
||||
var _loc33_:int = 0;
|
||||
_loc28_ = 0;
|
||||
while(_loc28_ < 2)
|
||||
{
|
||||
_loc34_ = _loc25_[_loc28_];
|
||||
_loc15_ = b2Math.b2Dot(_loc13_,_loc34_.v) - _loc30_;
|
||||
if(_loc15_ <= 0)
|
||||
{
|
||||
_loc31_ = param1.points[_loc33_];
|
||||
_loc31_.separation = _loc15_;
|
||||
_loc31_.localPoint1 = b2Math.b2MulXT(param3,_loc34_.v);
|
||||
_loc31_.localPoint2 = b2Math.b2MulXT(param5,_loc34_.v);
|
||||
_loc31_.id.key = _loc34_.id._key;
|
||||
_loc31_.id.features.flip = _loc21_;
|
||||
_loc33_++;
|
||||
}
|
||||
_loc28_++;
|
||||
}
|
||||
param1.pointCount = _loc33_;
|
||||
}
|
||||
|
||||
public static function b2CollideCircles(param1:b2Manifold, param2:b2CircleShape, param3:b2XForm, param4:b2CircleShape, param5:b2XForm) : void
|
||||
{
|
||||
var _loc23_:b2Mat22 = null;
|
||||
var _loc21_:b2Vec2 = null;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
param1.pointCount = 0;
|
||||
_loc23_ = param3.R;
|
||||
_loc21_ = param2.m_localPosition;
|
||||
var _loc22_:Number = param3.position.x + (_loc23_.col1.x * _loc21_.x + _loc23_.col2.x * _loc21_.y);
|
||||
var _loc24_:Number = param3.position.y + (_loc23_.col1.y * _loc21_.x + _loc23_.col2.y * _loc21_.y);
|
||||
_loc23_ = param5.R;
|
||||
_loc21_ = param4.m_localPosition;
|
||||
var _loc11_:Number = param5.position.x + (_loc23_.col1.x * _loc21_.x + _loc23_.col2.x * _loc21_.y);
|
||||
var _loc10_:Number = param5.position.y + (_loc23_.col1.y * _loc21_.x + _loc23_.col2.y * _loc21_.y);
|
||||
var _loc19_:Number = _loc11_ - _loc22_;
|
||||
var _loc20_:Number = _loc10_ - _loc24_;
|
||||
var _loc15_:Number = _loc19_ * _loc19_ + _loc20_ * _loc20_;
|
||||
var _loc25_:Number = param2.m_radius;
|
||||
var _loc6_:Number = param4.m_radius;
|
||||
var _loc8_:Number = _loc25_ + _loc6_;
|
||||
if(_loc15_ > _loc8_ * _loc8_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_loc15_ < Number.MIN_VALUE)
|
||||
{
|
||||
_loc9_ = -_loc8_;
|
||||
param1.normal.Set(0,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = Math.sqrt(_loc15_);
|
||||
_loc9_ = _loc7_ - _loc8_;
|
||||
_loc12_ = 1 / _loc7_;
|
||||
param1.normal.x = _loc12_ * _loc19_;
|
||||
param1.normal.y = _loc12_ * _loc20_;
|
||||
}
|
||||
param1.pointCount = 1;
|
||||
var _loc18_:b2ManifoldPoint = param1.points[0];
|
||||
_loc18_.id.key = 0;
|
||||
_loc18_.separation = _loc9_;
|
||||
_loc22_ += _loc25_ * param1.normal.x;
|
||||
_loc24_ += _loc25_ * param1.normal.y;
|
||||
_loc11_ -= _loc6_ * param1.normal.x;
|
||||
_loc10_ -= _loc6_ * param1.normal.y;
|
||||
var _loc16_:Number = 0.5 * (_loc22_ + _loc11_);
|
||||
var _loc17_:Number = 0.5 * (_loc24_ + _loc10_);
|
||||
var _loc13_:Number = _loc16_ - param3.position.x;
|
||||
var _loc14_:Number = _loc17_ - param3.position.y;
|
||||
_loc18_.localPoint1.x = _loc13_ * param3.R.col1.x + _loc14_ * param3.R.col1.y;
|
||||
_loc18_.localPoint1.y = _loc13_ * param3.R.col2.x + _loc14_ * param3.R.col2.y;
|
||||
_loc13_ = _loc16_ - param5.position.x;
|
||||
_loc14_ = _loc17_ - param5.position.y;
|
||||
_loc18_.localPoint2.x = _loc13_ * param5.R.col1.x + _loc14_ * param5.R.col1.y;
|
||||
_loc18_.localPoint2.y = _loc13_ * param5.R.col2.x + _loc14_ * param5.R.col2.y;
|
||||
}
|
||||
|
||||
public static function b2CollidePolygonAndCircle(param1:b2Manifold, param2:b2PolygonShape, param3:b2XForm, param4:b2CircleShape, param5:b2XForm) : void
|
||||
{
|
||||
var _loc25_:b2ManifoldPoint = null;
|
||||
var _loc28_:Number = NaN;
|
||||
var _loc29_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc31_:b2Vec2 = null;
|
||||
var _loc32_:b2Mat22 = null;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc21_:int = 0;
|
||||
var _loc27_:Number = NaN;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
param1.pointCount = 0;
|
||||
_loc32_ = param5.R;
|
||||
_loc31_ = param4.m_localPosition;
|
||||
var _loc14_:Number = param5.position.x + (_loc32_.col1.x * _loc31_.x + _loc32_.col2.x * _loc31_.y);
|
||||
var _loc16_:Number = param5.position.y + (_loc32_.col1.y * _loc31_.x + _loc32_.col2.y * _loc31_.y);
|
||||
_loc28_ = _loc14_ - param3.position.x;
|
||||
_loc29_ = _loc16_ - param3.position.y;
|
||||
_loc32_ = param3.R;
|
||||
var _loc11_:Number = _loc28_ * _loc32_.col1.x + _loc29_ * _loc32_.col1.y;
|
||||
var _loc10_:Number = _loc28_ * _loc32_.col2.x + _loc29_ * _loc32_.col2.y;
|
||||
var _loc18_:* = 0;
|
||||
var _loc15_:Number = -1.7976931348623157e+308;
|
||||
var _loc17_:Number = param4.m_radius;
|
||||
var _loc23_:int = param2.m_vertexCount;
|
||||
var _loc6_:Array = param2.m_vertices;
|
||||
var _loc34_:Array = param2.m_normals;
|
||||
_loc21_ = 0;
|
||||
while(_loc21_ < _loc23_)
|
||||
{
|
||||
_loc31_ = _loc6_[_loc21_];
|
||||
_loc28_ = _loc11_ - _loc31_.x;
|
||||
_loc29_ = _loc10_ - _loc31_.y;
|
||||
_loc31_ = _loc34_[_loc21_];
|
||||
_loc27_ = _loc31_.x * _loc28_ + _loc31_.y * _loc29_;
|
||||
if(_loc27_ > _loc17_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_loc27_ > _loc15_)
|
||||
{
|
||||
_loc15_ = _loc27_;
|
||||
_loc18_ = _loc21_;
|
||||
}
|
||||
_loc21_++;
|
||||
}
|
||||
if(_loc15_ < Number.MIN_VALUE)
|
||||
{
|
||||
param1.pointCount = 1;
|
||||
_loc31_ = _loc34_[_loc18_];
|
||||
_loc32_ = param3.R;
|
||||
param1.normal.x = _loc32_.col1.x * _loc31_.x + _loc32_.col2.x * _loc31_.y;
|
||||
param1.normal.y = _loc32_.col1.y * _loc31_.x + _loc32_.col2.y * _loc31_.y;
|
||||
_loc25_ = param1.points[0];
|
||||
_loc25_.id.features.incidentEdge = _loc18_;
|
||||
_loc25_.id.features.incidentVertex = 255;
|
||||
_loc25_.id.features.referenceEdge = 0;
|
||||
_loc25_.id.features.flip = 0;
|
||||
_loc8_ = _loc14_ - _loc17_ * param1.normal.x;
|
||||
_loc9_ = _loc16_ - _loc17_ * param1.normal.y;
|
||||
_loc28_ = _loc8_ - param3.position.x;
|
||||
_loc29_ = _loc9_ - param3.position.y;
|
||||
_loc32_ = param3.R;
|
||||
_loc25_.localPoint1.x = _loc28_ * _loc32_.col1.x + _loc29_ * _loc32_.col1.y;
|
||||
_loc25_.localPoint1.y = _loc28_ * _loc32_.col2.x + _loc29_ * _loc32_.col2.y;
|
||||
_loc28_ = _loc8_ - param5.position.x;
|
||||
_loc29_ = _loc9_ - param5.position.y;
|
||||
_loc32_ = param5.R;
|
||||
_loc25_.localPoint2.x = _loc28_ * _loc32_.col1.x + _loc29_ * _loc32_.col1.y;
|
||||
_loc25_.localPoint2.y = _loc28_ * _loc32_.col2.x + _loc29_ * _loc32_.col2.y;
|
||||
_loc25_.separation = _loc15_ - _loc17_;
|
||||
return;
|
||||
}
|
||||
var _loc26_:Number = _loc18_;
|
||||
var _loc24_:int = _loc26_ + 1 < _loc23_ ? _loc26_ + 1 : 0;
|
||||
_loc31_ = _loc6_[_loc26_];
|
||||
var _loc33_:b2Vec2 = _loc6_[_loc24_];
|
||||
var _loc12_:Number = _loc33_.x - _loc31_.x;
|
||||
var _loc13_:Number = _loc33_.y - _loc31_.y;
|
||||
var _loc19_:Number = Math.sqrt(_loc12_ * _loc12_ + _loc13_ * _loc13_);
|
||||
_loc12_ /= _loc19_;
|
||||
_loc13_ /= _loc19_;
|
||||
_loc28_ = _loc11_ - _loc31_.x;
|
||||
_loc29_ = _loc10_ - _loc31_.y;
|
||||
var _loc30_:Number = _loc28_ * _loc12_ + _loc29_ * _loc13_;
|
||||
_loc25_ = param1.points[0];
|
||||
if(_loc30_ <= 0)
|
||||
{
|
||||
_loc20_ = _loc31_.x;
|
||||
_loc22_ = _loc31_.y;
|
||||
_loc25_.id.features.incidentEdge = 255;
|
||||
_loc25_.id.features.incidentVertex = _loc26_;
|
||||
}
|
||||
else if(_loc30_ >= _loc19_)
|
||||
{
|
||||
_loc20_ = _loc33_.x;
|
||||
_loc22_ = _loc33_.y;
|
||||
_loc25_.id.features.incidentEdge = 255;
|
||||
_loc25_.id.features.incidentVertex = _loc24_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc20_ = _loc12_ * _loc30_ + _loc31_.x;
|
||||
_loc22_ = _loc13_ * _loc30_ + _loc31_.y;
|
||||
_loc25_.id.features.incidentEdge = _loc18_;
|
||||
_loc25_.id.features.incidentVertex = 255;
|
||||
}
|
||||
_loc28_ = _loc11_ - _loc20_;
|
||||
_loc29_ = _loc10_ - _loc22_;
|
||||
_loc7_ = Math.sqrt(_loc28_ * _loc28_ + _loc29_ * _loc29_);
|
||||
_loc28_ /= _loc7_;
|
||||
_loc29_ /= _loc7_;
|
||||
if(_loc7_ > _loc17_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
param1.pointCount = 1;
|
||||
_loc32_ = param3.R;
|
||||
param1.normal.x = _loc32_.col1.x * _loc28_ + _loc32_.col2.x * _loc29_;
|
||||
param1.normal.y = _loc32_.col1.y * _loc28_ + _loc32_.col2.y * _loc29_;
|
||||
_loc8_ = _loc14_ - _loc17_ * param1.normal.x;
|
||||
_loc9_ = _loc16_ - _loc17_ * param1.normal.y;
|
||||
_loc28_ = _loc8_ - param3.position.x;
|
||||
_loc29_ = _loc9_ - param3.position.y;
|
||||
_loc32_ = param3.R;
|
||||
_loc25_.localPoint1.x = _loc28_ * _loc32_.col1.x + _loc29_ * _loc32_.col1.y;
|
||||
_loc25_.localPoint1.y = _loc28_ * _loc32_.col2.x + _loc29_ * _loc32_.col2.y;
|
||||
_loc28_ = _loc8_ - param5.position.x;
|
||||
_loc29_ = _loc9_ - param5.position.y;
|
||||
_loc32_ = param5.R;
|
||||
_loc25_.localPoint2.x = _loc28_ * _loc32_.col1.x + _loc29_ * _loc32_.col1.y;
|
||||
_loc25_.localPoint2.y = _loc28_ * _loc32_.col2.x + _loc29_ * _loc32_.col2.y;
|
||||
_loc25_.separation = _loc7_ - _loc17_;
|
||||
_loc25_.id.features.referenceEdge = 0;
|
||||
_loc25_.id.features.flip = 0;
|
||||
}
|
||||
|
||||
public static function b2TestOverlap(param1:b2AABB, param2:b2AABB) : Boolean
|
||||
{
|
||||
var _loc6_:b2Vec2 = param2.lowerBound;
|
||||
var _loc8_:b2Vec2 = param1.upperBound;
|
||||
var _loc3_:Number = _loc6_.x - _loc8_.x;
|
||||
var _loc7_:Number = _loc6_.y - _loc8_.y;
|
||||
_loc6_ = param1.lowerBound;
|
||||
_loc8_ = param2.upperBound;
|
||||
var _loc5_:Number = _loc6_.x - _loc8_.x;
|
||||
var _loc4_:Number = _loc6_.y - _loc8_.y;
|
||||
if(_loc3_ > 0 || _loc7_ > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(_loc5_ > 0 || _loc4_ > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
public class b2ContactID
|
||||
{
|
||||
|
||||
public var features:Features = new Features();
|
||||
|
||||
public var _key:uint;
|
||||
|
||||
public function b2ContactID()
|
||||
{
|
||||
super();
|
||||
features._m_id = this;
|
||||
}
|
||||
|
||||
public function Set(param1:b2ContactID) : void
|
||||
{
|
||||
key = param1._key;
|
||||
}
|
||||
|
||||
public function Copy() : b2ContactID
|
||||
{
|
||||
var _loc1_:b2ContactID = new b2ContactID();
|
||||
_loc1_.key = key;
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function get key() : uint
|
||||
{
|
||||
return _key;
|
||||
}
|
||||
|
||||
public function set key(param1:uint) : void
|
||||
{
|
||||
_key = param1;
|
||||
features._referenceEdge = _key & 0xFF;
|
||||
features._incidentEdge = (_key & 0xFF00) >> 8 & 0xFF;
|
||||
features._incidentVertex = (_key & 0xFF0000) >> 16 & 0xFF;
|
||||
features._flip = (_key & 0xFF000000) >> 24 & 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2ContactPoint
|
||||
{
|
||||
|
||||
public var shape1:b2Shape;
|
||||
|
||||
public var shape2:b2Shape;
|
||||
|
||||
public var position:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var velocity:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var normal:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var separation:Number;
|
||||
|
||||
public var friction:Number;
|
||||
|
||||
public var restitution:Number;
|
||||
|
||||
public var id:b2ContactID = new b2ContactID();
|
||||
|
||||
public function b2ContactPoint()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Collision.Shapes.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
|
||||
public class b2Distance
|
||||
{
|
||||
|
||||
public static var g_GJK_Iterations:int = 0;
|
||||
|
||||
private static var s_p1s:Array = [new b2Vec2(),new b2Vec2(),new b2Vec2()];
|
||||
|
||||
private static var s_p2s:Array = [new b2Vec2(),new b2Vec2(),new b2Vec2()];
|
||||
|
||||
private static var s_points:Array = [new b2Vec2(),new b2Vec2(),new b2Vec2()];
|
||||
|
||||
private static var gPoint:b2Point = new b2Point();
|
||||
|
||||
public function b2Distance()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function ProcessTwo(param1:b2Vec2, param2:b2Vec2, param3:Array, param4:Array, param5:Array) : int
|
||||
{
|
||||
var _loc16_:b2Vec2 = param5[0];
|
||||
var _loc17_:b2Vec2 = param5[1];
|
||||
var _loc7_:b2Vec2 = param3[0];
|
||||
var _loc9_:b2Vec2 = param3[1];
|
||||
var _loc6_:b2Vec2 = param4[0];
|
||||
var _loc8_:b2Vec2 = param4[1];
|
||||
var _loc10_:Number = -_loc17_.x;
|
||||
var _loc11_:Number = -_loc17_.y;
|
||||
var _loc14_:Number = _loc16_.x - _loc17_.x;
|
||||
var _loc15_:Number = _loc16_.y - _loc17_.y;
|
||||
var _loc12_:Number = Math.sqrt(_loc14_ * _loc14_ + _loc15_ * _loc15_);
|
||||
_loc14_ /= _loc12_;
|
||||
_loc15_ /= _loc12_;
|
||||
var _loc13_:Number = _loc10_ * _loc14_ + _loc11_ * _loc15_;
|
||||
if(_loc13_ <= 0 || _loc12_ < Number.MIN_VALUE)
|
||||
{
|
||||
param1.SetV(_loc9_);
|
||||
param2.SetV(_loc8_);
|
||||
_loc7_.SetV(_loc9_);
|
||||
_loc6_.SetV(_loc8_);
|
||||
_loc16_.SetV(_loc17_);
|
||||
return 1;
|
||||
}
|
||||
_loc13_ /= _loc12_;
|
||||
param1.x = _loc9_.x + _loc13_ * (_loc7_.x - _loc9_.x);
|
||||
param1.y = _loc9_.y + _loc13_ * (_loc7_.y - _loc9_.y);
|
||||
param2.x = _loc8_.x + _loc13_ * (_loc6_.x - _loc8_.x);
|
||||
param2.y = _loc8_.y + _loc13_ * (_loc6_.y - _loc8_.y);
|
||||
return 2;
|
||||
}
|
||||
|
||||
public static function ProcessThree(param1:b2Vec2, param2:b2Vec2, param3:Array, param4:Array, param5:Array) : int
|
||||
{
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc21_:b2Vec2 = param5[0];
|
||||
var _loc22_:b2Vec2 = param5[1];
|
||||
var _loc23_:b2Vec2 = param5[2];
|
||||
var _loc6_:b2Vec2 = param3[0];
|
||||
var _loc7_:b2Vec2 = param3[1];
|
||||
var _loc8_:b2Vec2 = param3[2];
|
||||
var _loc24_:b2Vec2 = param4[0];
|
||||
var _loc25_:b2Vec2 = param4[1];
|
||||
var _loc26_:b2Vec2 = param4[2];
|
||||
var _loc15_:Number = _loc21_.x;
|
||||
var _loc16_:Number = _loc21_.y;
|
||||
var _loc33_:Number = _loc22_.x;
|
||||
var _loc37_:Number = _loc22_.y;
|
||||
var _loc12_:Number = _loc23_.x;
|
||||
var _loc13_:Number = _loc23_.y;
|
||||
var _loc14_:Number = _loc33_ - _loc15_;
|
||||
var _loc17_:Number = _loc37_ - _loc16_;
|
||||
var _loc38_:Number = _loc12_ - _loc15_;
|
||||
var _loc34_:Number = _loc13_ - _loc16_;
|
||||
var _loc35_:Number = _loc12_ - _loc33_;
|
||||
var _loc40_:Number = _loc13_ - _loc37_;
|
||||
var _loc19_:Number = -(_loc15_ * _loc14_ + _loc16_ * _loc17_);
|
||||
var _loc10_:Number = _loc33_ * _loc14_ + _loc37_ * _loc17_;
|
||||
var _loc41_:Number = -(_loc15_ * _loc38_ + _loc16_ * _loc34_);
|
||||
var _loc31_:Number = _loc12_ * _loc38_ + _loc13_ * _loc34_;
|
||||
var _loc18_:Number = -(_loc33_ * _loc35_ + _loc37_ * _loc40_);
|
||||
var _loc9_:Number = _loc12_ * _loc35_ + _loc13_ * _loc40_;
|
||||
if(_loc31_ <= 0 && _loc9_ <= 0)
|
||||
{
|
||||
param1.SetV(_loc8_);
|
||||
param2.SetV(_loc26_);
|
||||
_loc6_.SetV(_loc8_);
|
||||
_loc24_.SetV(_loc26_);
|
||||
_loc21_.SetV(_loc23_);
|
||||
return 1;
|
||||
}
|
||||
var _loc30_:Number = _loc14_ * _loc34_ - _loc17_ * _loc38_;
|
||||
var _loc29_:Number = _loc30_ * (_loc15_ * _loc37_ - _loc16_ * _loc33_);
|
||||
var _loc27_:Number = _loc30_ * (_loc33_ * _loc13_ - _loc37_ * _loc12_);
|
||||
if(_loc27_ <= 0 && _loc18_ >= 0 && _loc9_ >= 0 && _loc18_ + _loc9_ > 0)
|
||||
{
|
||||
_loc11_ = _loc18_ / (_loc18_ + _loc9_);
|
||||
param1.x = _loc7_.x + _loc11_ * (_loc8_.x - _loc7_.x);
|
||||
param1.y = _loc7_.y + _loc11_ * (_loc8_.y - _loc7_.y);
|
||||
param2.x = _loc25_.x + _loc11_ * (_loc26_.x - _loc25_.x);
|
||||
param2.y = _loc25_.y + _loc11_ * (_loc26_.y - _loc25_.y);
|
||||
_loc6_.SetV(_loc8_);
|
||||
_loc24_.SetV(_loc26_);
|
||||
_loc21_.SetV(_loc23_);
|
||||
return 2;
|
||||
}
|
||||
var _loc28_:Number = _loc30_ * (_loc12_ * _loc16_ - _loc13_ * _loc15_);
|
||||
if(_loc28_ <= 0 && _loc41_ >= 0 && _loc31_ >= 0 && _loc41_ + _loc31_ > 0)
|
||||
{
|
||||
_loc11_ = _loc41_ / (_loc41_ + _loc31_);
|
||||
param1.x = _loc6_.x + _loc11_ * (_loc8_.x - _loc6_.x);
|
||||
param1.y = _loc6_.y + _loc11_ * (_loc8_.y - _loc6_.y);
|
||||
param2.x = _loc24_.x + _loc11_ * (_loc26_.x - _loc24_.x);
|
||||
param2.y = _loc24_.y + _loc11_ * (_loc26_.y - _loc24_.y);
|
||||
_loc7_.SetV(_loc8_);
|
||||
_loc25_.SetV(_loc26_);
|
||||
_loc22_.SetV(_loc23_);
|
||||
return 2;
|
||||
}
|
||||
var _loc20_:Number = _loc27_ + _loc28_ + _loc29_;
|
||||
_loc20_ = 1 / _loc20_;
|
||||
var _loc32_:Number = _loc27_ * _loc20_;
|
||||
var _loc36_:Number = _loc28_ * _loc20_;
|
||||
var _loc39_:Number = 1 - _loc32_ - _loc36_;
|
||||
param1.x = _loc32_ * _loc6_.x + _loc36_ * _loc7_.x + _loc39_ * _loc8_.x;
|
||||
param1.y = _loc32_ * _loc6_.y + _loc36_ * _loc7_.y + _loc39_ * _loc8_.y;
|
||||
param2.x = _loc32_ * _loc24_.x + _loc36_ * _loc25_.x + _loc39_ * _loc26_.x;
|
||||
param2.y = _loc32_ * _loc24_.y + _loc36_ * _loc25_.y + _loc39_ * _loc26_.y;
|
||||
return 3;
|
||||
}
|
||||
|
||||
public static function InPoints(param1:b2Vec2, param2:Array, param3:int) : Boolean
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc6_:b2Vec2 = null;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc4_:Number = 100 * Number.MIN_VALUE;
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < param3)
|
||||
{
|
||||
_loc6_ = param2[_loc8_];
|
||||
_loc5_ = Math.abs(param1.x - _loc6_.x);
|
||||
_loc7_ = Math.abs(param1.y - _loc6_.y);
|
||||
_loc9_ = Math.max(Math.abs(param1.x),Math.abs(_loc6_.x));
|
||||
_loc10_ = Math.max(Math.abs(param1.y),Math.abs(_loc6_.y));
|
||||
if(_loc5_ < _loc4_ * (_loc9_ + 1) && _loc7_ < _loc4_ * (_loc10_ + 1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function DistanceGeneric(param1:b2Vec2, param2:b2Vec2, param3:*, param4:b2XForm, param5:*, param6:b2XForm) : Number
|
||||
{
|
||||
var _loc20_:b2Vec2 = null;
|
||||
var _loc9_:int = 0;
|
||||
_loc9_ = 20;
|
||||
var _loc14_:int = 0;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc21_:b2Vec2 = null;
|
||||
var _loc22_:b2Vec2 = null;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc23_:Number = NaN;
|
||||
var _loc15_:int = 0;
|
||||
var _loc19_:Array = s_p1s;
|
||||
var _loc17_:Array = s_p2s;
|
||||
var _loc16_:Array = s_points;
|
||||
var _loc18_:int = 0;
|
||||
param1.SetV(param3.GetFirstVertex(param4));
|
||||
param2.SetV(param5.GetFirstVertex(param6));
|
||||
var _loc13_:Number = 0;
|
||||
_loc14_ = 0;
|
||||
while(_loc14_ < 20)
|
||||
{
|
||||
_loc10_ = param2.x - param1.x;
|
||||
_loc12_ = param2.y - param1.y;
|
||||
_loc21_ = param3.Support(param4,_loc10_,_loc12_);
|
||||
_loc22_ = param5.Support(param6,-_loc10_,-_loc12_);
|
||||
_loc13_ = _loc10_ * _loc10_ + _loc12_ * _loc12_;
|
||||
_loc7_ = _loc22_.x - _loc21_.x;
|
||||
_loc11_ = _loc22_.y - _loc21_.y;
|
||||
_loc8_ = _loc10_ * _loc7_ + _loc12_ * _loc11_;
|
||||
if(_loc13_ - _loc8_ <= 0.01 * _loc13_)
|
||||
{
|
||||
if(_loc18_ == 0)
|
||||
{
|
||||
param1.SetV(_loc21_);
|
||||
param2.SetV(_loc22_);
|
||||
}
|
||||
g_GJK_Iterations = _loc14_;
|
||||
return Math.sqrt(_loc13_);
|
||||
}
|
||||
switch(_loc18_)
|
||||
{
|
||||
case 0:
|
||||
_loc20_ = _loc19_[0];
|
||||
_loc20_.SetV(_loc21_);
|
||||
_loc20_ = _loc17_[0];
|
||||
_loc20_.SetV(_loc22_);
|
||||
_loc20_ = _loc16_[0];
|
||||
_loc20_.x = _loc7_;
|
||||
_loc20_.y = _loc11_;
|
||||
param1.SetV(_loc19_[0]);
|
||||
param2.SetV(_loc17_[0]);
|
||||
_loc18_++;
|
||||
break;
|
||||
case 1:
|
||||
_loc20_ = _loc19_[1];
|
||||
_loc20_.SetV(_loc21_);
|
||||
_loc20_ = _loc17_[1];
|
||||
_loc20_.SetV(_loc22_);
|
||||
_loc20_ = _loc16_[1];
|
||||
_loc20_.x = _loc7_;
|
||||
_loc20_.y = _loc11_;
|
||||
_loc18_ = ProcessTwo(param1,param2,_loc19_,_loc17_,_loc16_);
|
||||
break;
|
||||
case 2:
|
||||
_loc20_ = _loc19_[2];
|
||||
_loc20_.SetV(_loc21_);
|
||||
_loc20_ = _loc17_[2];
|
||||
_loc20_.SetV(_loc22_);
|
||||
_loc20_ = _loc16_[2];
|
||||
_loc20_.x = _loc7_;
|
||||
_loc20_.y = _loc11_;
|
||||
_loc18_ = ProcessThree(param1,param2,_loc19_,_loc17_,_loc16_);
|
||||
}
|
||||
if(_loc18_ == 3)
|
||||
{
|
||||
g_GJK_Iterations = _loc14_;
|
||||
return 0;
|
||||
}
|
||||
_loc23_ = -1.7976931348623157e+308;
|
||||
_loc15_ = 0;
|
||||
while(_loc15_ < _loc18_)
|
||||
{
|
||||
_loc20_ = _loc16_[_loc15_];
|
||||
_loc23_ = b2Math.b2Max(_loc23_,_loc20_.x * _loc20_.x + _loc20_.y * _loc20_.y);
|
||||
_loc15_++;
|
||||
}
|
||||
if(_loc18_ == 3 || _loc13_ <= 100 * Number.MIN_VALUE * _loc23_)
|
||||
{
|
||||
g_GJK_Iterations = _loc14_;
|
||||
_loc10_ = param2.x - param1.x;
|
||||
_loc12_ = param2.y - param1.y;
|
||||
_loc13_ = _loc10_ * _loc10_ + _loc12_ * _loc12_;
|
||||
return Math.sqrt(_loc13_);
|
||||
}
|
||||
_loc14_++;
|
||||
}
|
||||
g_GJK_Iterations = 20;
|
||||
return Math.sqrt(_loc13_);
|
||||
}
|
||||
|
||||
public static function DistanceCC(param1:b2Vec2, param2:b2Vec2, param3:b2CircleShape, param4:b2XForm, param5:b2CircleShape, param6:b2XForm) : Number
|
||||
{
|
||||
var _loc16_:b2Mat22 = null;
|
||||
var _loc12_:b2Vec2 = null;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
_loc16_ = param4.R;
|
||||
_loc12_ = param3.m_localPosition;
|
||||
var _loc13_:Number = param4.position.x + (_loc16_.col1.x * _loc12_.x + _loc16_.col2.x * _loc12_.y);
|
||||
var _loc17_:Number = param4.position.y + (_loc16_.col1.y * _loc12_.x + _loc16_.col2.y * _loc12_.y);
|
||||
_loc16_ = param6.R;
|
||||
_loc12_ = param5.m_localPosition;
|
||||
var _loc15_:Number = param6.position.x + (_loc16_.col1.x * _loc12_.x + _loc16_.col2.x * _loc12_.y);
|
||||
var _loc14_:Number = param6.position.y + (_loc16_.col1.y * _loc12_.x + _loc16_.col2.y * _loc12_.y);
|
||||
var _loc10_:Number = _loc15_ - _loc13_;
|
||||
var _loc11_:Number = _loc14_ - _loc17_;
|
||||
var _loc18_:Number = _loc10_ * _loc10_ + _loc11_ * _loc11_;
|
||||
var _loc19_:Number = param3.m_radius - 0.04;
|
||||
var _loc7_:Number = param5.m_radius - 0.04;
|
||||
var _loc9_:Number = _loc19_ + _loc7_;
|
||||
if(_loc18_ > _loc9_ * _loc9_)
|
||||
{
|
||||
_loc20_ = Math.sqrt(_loc18_);
|
||||
_loc10_ /= _loc20_;
|
||||
_loc11_ /= _loc20_;
|
||||
_loc8_ = _loc20_ - _loc9_;
|
||||
param1.x = _loc13_ + _loc19_ * _loc10_;
|
||||
param1.y = _loc17_ + _loc19_ * _loc11_;
|
||||
param2.x = _loc15_ - _loc7_ * _loc10_;
|
||||
param2.y = _loc14_ - _loc7_ * _loc11_;
|
||||
return _loc8_;
|
||||
}
|
||||
if(_loc18_ > Number.MIN_VALUE * Number.MIN_VALUE)
|
||||
{
|
||||
_loc20_ = Math.sqrt(_loc18_);
|
||||
_loc10_ /= _loc20_;
|
||||
_loc11_ /= _loc20_;
|
||||
param1.x = _loc13_ + _loc19_ * _loc10_;
|
||||
param1.y = _loc17_ + _loc19_ * _loc11_;
|
||||
param2.x = param1.x;
|
||||
param2.y = param1.y;
|
||||
return 0;
|
||||
}
|
||||
param1.x = _loc13_;
|
||||
param1.y = _loc17_;
|
||||
param2.x = param1.x;
|
||||
param2.y = param1.y;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function DistancePC(param1:b2Vec2, param2:b2Vec2, param3:b2PolygonShape, param4:b2XForm, param5:b2CircleShape, param6:b2XForm) : Number
|
||||
{
|
||||
var _loc13_:b2Mat22 = null;
|
||||
var _loc12_:b2Vec2 = null;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc8_:b2Point = gPoint;
|
||||
_loc12_ = param5.m_localPosition;
|
||||
_loc13_ = param6.R;
|
||||
_loc8_.p.x = param6.position.x + (_loc13_.col1.x * _loc12_.x + _loc13_.col2.x * _loc12_.y);
|
||||
_loc8_.p.y = param6.position.y + (_loc13_.col1.y * _loc12_.x + _loc13_.col2.y * _loc12_.y);
|
||||
var _loc7_:Number = DistanceGeneric(param1,param2,param3,param4,_loc8_,b2Math.b2XForm_identity);
|
||||
var _loc9_:Number = param5.m_radius - 0.04;
|
||||
if(_loc7_ > _loc9_)
|
||||
{
|
||||
_loc7_ -= _loc9_;
|
||||
_loc10_ = param2.x - param1.x;
|
||||
_loc11_ = param2.y - param1.y;
|
||||
_loc14_ = Math.sqrt(_loc10_ * _loc10_ + _loc11_ * _loc11_);
|
||||
_loc10_ /= _loc14_;
|
||||
_loc11_ /= _loc14_;
|
||||
param2.x -= _loc9_ * _loc10_;
|
||||
param2.y -= _loc9_ * _loc11_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = 0;
|
||||
param2.x = param1.x;
|
||||
param2.y = param1.y;
|
||||
}
|
||||
return _loc7_;
|
||||
}
|
||||
|
||||
public static function Distance(param1:b2Vec2, param2:b2Vec2, param3:b2Shape, param4:b2XForm, param5:b2Shape, param6:b2XForm) : Number
|
||||
{
|
||||
var _loc8_:int = param3.m_type;
|
||||
var _loc7_:int = param5.m_type;
|
||||
if(_loc8_ == 0 && _loc7_ == 0)
|
||||
{
|
||||
return DistanceCC(param1,param2,param3 as b2CircleShape,param4,param5 as b2CircleShape,param6);
|
||||
}
|
||||
if(_loc8_ == 1 && _loc7_ == 0)
|
||||
{
|
||||
return DistancePC(param1,param2,param3 as b2PolygonShape,param4,param5 as b2CircleShape,param6);
|
||||
}
|
||||
if(_loc8_ == 0 && _loc7_ == 1)
|
||||
{
|
||||
return DistancePC(param2,param1,param5 as b2PolygonShape,param6,param3 as b2CircleShape,param4);
|
||||
}
|
||||
if(_loc8_ == 1 && _loc7_ == 1)
|
||||
{
|
||||
return DistanceGeneric(param1,param2,param3 as b2PolygonShape,param4,param5 as b2PolygonShape,param6);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
|
||||
public class b2Manifold
|
||||
{
|
||||
|
||||
public var points:Array;
|
||||
|
||||
public var normal:b2Vec2;
|
||||
|
||||
public var pointCount:int = 0;
|
||||
|
||||
public function b2Manifold()
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
super();
|
||||
points = new Array(2);
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 2)
|
||||
{
|
||||
points[_loc1_] = new b2ManifoldPoint();
|
||||
_loc1_++;
|
||||
}
|
||||
normal = new b2Vec2();
|
||||
}
|
||||
|
||||
public function Reset() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 2)
|
||||
{
|
||||
(points[_loc1_] as b2ManifoldPoint).Reset();
|
||||
_loc1_++;
|
||||
}
|
||||
normal.SetZero();
|
||||
pointCount = 0;
|
||||
}
|
||||
|
||||
public function Set(param1:b2Manifold) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
pointCount = param1.pointCount;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 2)
|
||||
{
|
||||
(points[_loc2_] as b2ManifoldPoint).Set(param1.points[_loc2_]);
|
||||
_loc2_++;
|
||||
}
|
||||
normal.SetV(param1.normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2ManifoldPoint
|
||||
{
|
||||
|
||||
public var localPoint1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var localPoint2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var separation:Number;
|
||||
|
||||
public var normalImpulse:Number;
|
||||
|
||||
public var tangentImpulse:Number;
|
||||
|
||||
public var id:b2ContactID = new b2ContactID();
|
||||
|
||||
public function b2ManifoldPoint()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function Reset() : void
|
||||
{
|
||||
localPoint1.SetZero();
|
||||
localPoint2.SetZero();
|
||||
separation = 0;
|
||||
normalImpulse = 0;
|
||||
tangentImpulse = 0;
|
||||
id.key = 0;
|
||||
}
|
||||
|
||||
public function Set(param1:b2ManifoldPoint) : void
|
||||
{
|
||||
localPoint1.SetV(param1.localPoint1);
|
||||
localPoint2.SetV(param1.localPoint2);
|
||||
separation = param1.separation;
|
||||
normalImpulse = param1.normalImpulse;
|
||||
tangentImpulse = param1.tangentImpulse;
|
||||
id.key = param1.id.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.Math.b2Mat22;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2OBB
|
||||
{
|
||||
|
||||
public var R:b2Mat22 = new b2Mat22();
|
||||
|
||||
public var center:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var extents:b2Vec2 = new b2Vec2();
|
||||
|
||||
public function b2OBB()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
public class b2Pair
|
||||
{
|
||||
|
||||
public static var b2_nullPair:uint = 65535;
|
||||
|
||||
public static var b2_nullProxy:uint = 65535;
|
||||
|
||||
public static var b2_tableCapacity:int = 4096;
|
||||
|
||||
public static var e_pairBuffered:uint = 1;
|
||||
|
||||
public static var e_pairRemoved:uint = 2;
|
||||
|
||||
public static var e_pairFinal:uint = 4;
|
||||
|
||||
public static var b2_tableMask:int = b2_tableCapacity - 1;
|
||||
|
||||
public var userData:* = null;
|
||||
|
||||
public var proxyId1:uint;
|
||||
|
||||
public var proxyId2:uint;
|
||||
|
||||
public var next:uint;
|
||||
|
||||
public var status:uint;
|
||||
|
||||
public function b2Pair()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function SetBuffered() : void
|
||||
{
|
||||
status |= e_pairBuffered;
|
||||
}
|
||||
|
||||
public function ClearBuffered() : void
|
||||
{
|
||||
status &= ~e_pairBuffered;
|
||||
}
|
||||
|
||||
public function IsBuffered() : Boolean
|
||||
{
|
||||
return (status & e_pairBuffered) == e_pairBuffered;
|
||||
}
|
||||
|
||||
public function SetRemoved() : void
|
||||
{
|
||||
status |= e_pairRemoved;
|
||||
}
|
||||
|
||||
public function ClearRemoved() : void
|
||||
{
|
||||
status &= ~e_pairRemoved;
|
||||
}
|
||||
|
||||
public function IsRemoved() : Boolean
|
||||
{
|
||||
return (status & e_pairRemoved) == e_pairRemoved;
|
||||
}
|
||||
|
||||
public function SetFinal() : void
|
||||
{
|
||||
status |= e_pairFinal;
|
||||
}
|
||||
|
||||
public function IsFinal() : Boolean
|
||||
{
|
||||
return (status & e_pairFinal) == e_pairFinal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
public class b2PairCallback
|
||||
{
|
||||
|
||||
public function b2PairCallback()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function PairAdded(param1:*, param2:*) : *
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function PairRemoved(param1:*, param2:*, param3:*) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
|
||||
public class b2PairManager
|
||||
{
|
||||
|
||||
public var m_broadPhase:b2BroadPhase;
|
||||
|
||||
public var m_callback:b2PairCallback;
|
||||
|
||||
public var m_pairs:Array;
|
||||
|
||||
public var m_freePair:uint;
|
||||
|
||||
public var m_pairCount:int;
|
||||
|
||||
public var m_pairBuffer:Array;
|
||||
|
||||
public var m_pairBufferCount:int;
|
||||
|
||||
public var m_hashTable:Array;
|
||||
|
||||
public function b2PairManager()
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
super();
|
||||
m_hashTable = new Array(b2Pair.b2_tableCapacity);
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < b2Pair.b2_tableCapacity)
|
||||
{
|
||||
m_hashTable[_loc1_] = b2Pair.b2_nullPair;
|
||||
_loc1_++;
|
||||
}
|
||||
m_pairs = new Array(4096);
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 4096)
|
||||
{
|
||||
m_pairs[_loc1_] = new b2Pair();
|
||||
_loc1_++;
|
||||
}
|
||||
m_pairBuffer = new Array(4096);
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 4096)
|
||||
{
|
||||
m_pairBuffer[_loc1_] = new b2BufferedPair();
|
||||
_loc1_++;
|
||||
}
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 4096)
|
||||
{
|
||||
m_pairs[_loc1_].proxyId1 = b2Pair.b2_nullProxy;
|
||||
m_pairs[_loc1_].proxyId2 = b2Pair.b2_nullProxy;
|
||||
m_pairs[_loc1_].userData = null;
|
||||
m_pairs[_loc1_].status = 0;
|
||||
m_pairs[_loc1_].next = _loc1_ + 1;
|
||||
_loc1_++;
|
||||
}
|
||||
m_pairs[4095].next = b2Pair.b2_nullPair;
|
||||
m_pairCount = 0;
|
||||
m_pairBufferCount = 0;
|
||||
}
|
||||
|
||||
public static function Hash(param1:uint, param2:uint) : uint
|
||||
{
|
||||
var _loc3_:uint = uint(param2 << 16 & 0xFFFF0000 | param1);
|
||||
_loc3_ = ~_loc3_ + (_loc3_ << 15 & 0xFFFF8000);
|
||||
_loc3_ ^= _loc3_ >> 12 & 0x0FFFFF;
|
||||
_loc3_ += _loc3_ << 2 & 0xFFFFFFFC;
|
||||
_loc3_ ^= _loc3_ >> 4 & 0x0FFFFFFF;
|
||||
_loc3_ *= 2057;
|
||||
return uint(_loc3_ ^ _loc3_ >> 16 & 0xFFFF);
|
||||
}
|
||||
|
||||
public static function Equals(param1:b2Pair, param2:uint, param3:uint) : Boolean
|
||||
{
|
||||
return param1.proxyId1 == param2 && param1.proxyId2 == param3;
|
||||
}
|
||||
|
||||
public static function EqualsPair(param1:b2BufferedPair, param2:b2BufferedPair) : Boolean
|
||||
{
|
||||
return param1.proxyId1 == param2.proxyId1 && param1.proxyId2 == param2.proxyId2;
|
||||
}
|
||||
|
||||
public function Initialize(param1:b2BroadPhase, param2:b2PairCallback) : void
|
||||
{
|
||||
m_broadPhase = param1;
|
||||
m_callback = param2;
|
||||
}
|
||||
|
||||
public function AddBufferedPair(param1:int, param2:int) : void
|
||||
{
|
||||
var _loc3_:b2BufferedPair = null;
|
||||
var _loc4_:b2Pair = AddPair(param1,param2);
|
||||
if(_loc4_.IsBuffered() == false)
|
||||
{
|
||||
_loc4_.SetBuffered();
|
||||
_loc3_ = m_pairBuffer[m_pairBufferCount];
|
||||
_loc3_.proxyId1 = _loc4_.proxyId1;
|
||||
_loc3_.proxyId2 = _loc4_.proxyId2;
|
||||
m_pairBufferCount = m_pairBufferCount + 1;
|
||||
}
|
||||
_loc4_.ClearRemoved();
|
||||
if(b2BroadPhase.s_validate)
|
||||
{
|
||||
ValidateBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
public function RemoveBufferedPair(param1:int, param2:int) : void
|
||||
{
|
||||
var _loc3_:b2BufferedPair = null;
|
||||
var _loc4_:b2Pair = Find(param1,param2);
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_loc4_.IsBuffered() == false)
|
||||
{
|
||||
_loc4_.SetBuffered();
|
||||
_loc3_ = m_pairBuffer[m_pairBufferCount];
|
||||
_loc3_.proxyId1 = _loc4_.proxyId1;
|
||||
_loc3_.proxyId2 = _loc4_.proxyId2;
|
||||
m_pairBufferCount = m_pairBufferCount + 1;
|
||||
}
|
||||
_loc4_.SetRemoved();
|
||||
if(b2BroadPhase.s_validate)
|
||||
{
|
||||
ValidateBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
public function Commit() : void
|
||||
{
|
||||
var _loc1_:b2BufferedPair = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc6_:b2Pair = null;
|
||||
var _loc4_:b2Proxy = null;
|
||||
var _loc5_:b2Proxy = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc3_:Array = m_broadPhase.m_proxyPool;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < m_pairBufferCount)
|
||||
{
|
||||
_loc1_ = m_pairBuffer[_loc2_];
|
||||
_loc6_ = Find(_loc1_.proxyId1,_loc1_.proxyId2);
|
||||
_loc6_.ClearBuffered();
|
||||
_loc4_ = _loc3_[_loc6_.proxyId1];
|
||||
_loc5_ = _loc3_[_loc6_.proxyId2];
|
||||
if(_loc6_.IsRemoved())
|
||||
{
|
||||
if(_loc6_.IsFinal() == true)
|
||||
{
|
||||
m_callback.PairRemoved(_loc4_.userData,_loc5_.userData,_loc6_.userData);
|
||||
}
|
||||
_loc1_ = m_pairBuffer[_loc7_];
|
||||
_loc1_.proxyId1 = _loc6_.proxyId1;
|
||||
_loc1_.proxyId2 = _loc6_.proxyId2;
|
||||
_loc7_++;
|
||||
}
|
||||
else if(_loc6_.IsFinal() == false)
|
||||
{
|
||||
_loc6_.userData = m_callback.PairAdded(_loc4_.userData,_loc5_.userData);
|
||||
_loc6_.SetFinal();
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _loc7_)
|
||||
{
|
||||
_loc1_ = m_pairBuffer[_loc2_];
|
||||
RemovePair(_loc1_.proxyId1,_loc1_.proxyId2);
|
||||
_loc2_++;
|
||||
}
|
||||
m_pairBufferCount = 0;
|
||||
if(b2BroadPhase.s_validate)
|
||||
{
|
||||
ValidateTable();
|
||||
}
|
||||
}
|
||||
|
||||
private function AddPair(param1:uint, param2:uint) : b2Pair
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
var _loc6_:b2Pair = null;
|
||||
if(param1 > param2)
|
||||
{
|
||||
_loc3_ = param1;
|
||||
param1 = param2;
|
||||
param2 = _loc3_;
|
||||
}
|
||||
var _loc5_:uint = uint(Hash(param1,param2) & b2Pair.b2_tableMask);
|
||||
_loc6_ = _loc6_ = FindHash(param1,param2,_loc5_);
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
return _loc6_;
|
||||
}
|
||||
var _loc4_:uint = m_freePair;
|
||||
_loc6_ = m_pairs[_loc4_];
|
||||
m_freePair = _loc6_.next;
|
||||
_loc6_.proxyId1 = param1;
|
||||
_loc6_.proxyId2 = param2;
|
||||
_loc6_.status = 0;
|
||||
_loc6_.userData = null;
|
||||
_loc6_.next = m_hashTable[_loc5_];
|
||||
m_hashTable[_loc5_] = _loc4_;
|
||||
m_pairCount = m_pairCount + 1;
|
||||
return _loc6_;
|
||||
}
|
||||
|
||||
private function RemovePair(param1:uint, param2:uint) : *
|
||||
{
|
||||
var _loc8_:b2Pair = null;
|
||||
var _loc4_:* = 0;
|
||||
var _loc6_:* = 0;
|
||||
var _loc5_:* = undefined;
|
||||
if(param1 > param2)
|
||||
{
|
||||
_loc4_ = param1;
|
||||
param1 = param2;
|
||||
param2 = _loc4_;
|
||||
}
|
||||
var _loc9_:uint = uint(Hash(param1,param2) & b2Pair.b2_tableMask);
|
||||
var _loc3_:uint = uint(m_hashTable[_loc9_]);
|
||||
var _loc7_:b2Pair = null;
|
||||
while(_loc3_ != b2Pair.b2_nullPair)
|
||||
{
|
||||
if(Equals(m_pairs[_loc3_],param1,param2))
|
||||
{
|
||||
_loc6_ = _loc3_;
|
||||
_loc8_ = m_pairs[_loc3_];
|
||||
if(_loc7_)
|
||||
{
|
||||
_loc7_.next = _loc8_.next;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hashTable[_loc9_] = _loc8_.next;
|
||||
}
|
||||
_loc8_ = m_pairs[_loc6_];
|
||||
_loc5_ = _loc8_.userData;
|
||||
_loc8_.next = m_freePair;
|
||||
_loc8_.proxyId1 = b2Pair.b2_nullProxy;
|
||||
_loc8_.proxyId2 = b2Pair.b2_nullProxy;
|
||||
_loc8_.userData = null;
|
||||
_loc8_.status = 0;
|
||||
m_freePair = _loc6_;
|
||||
m_pairCount = m_pairCount - 1;
|
||||
return _loc5_;
|
||||
}
|
||||
_loc7_ = m_pairs[_loc3_];
|
||||
_loc3_ = _loc7_.next;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function Find(param1:uint, param2:uint) : b2Pair
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
if(param1 > param2)
|
||||
{
|
||||
_loc3_ = param1;
|
||||
param1 = param2;
|
||||
param2 = _loc3_;
|
||||
}
|
||||
var _loc4_:uint = uint(Hash(param1,param2) & b2Pair.b2_tableMask);
|
||||
return FindHash(param1,param2,_loc4_);
|
||||
}
|
||||
|
||||
private function FindHash(param1:uint, param2:uint, param3:uint) : b2Pair
|
||||
{
|
||||
var _loc5_:b2Pair = null;
|
||||
var _loc4_:uint = uint(m_hashTable[param3]);
|
||||
_loc5_ = m_pairs[_loc4_];
|
||||
while(_loc4_ != b2Pair.b2_nullPair && Equals(_loc5_,param1,param2) == false)
|
||||
{
|
||||
_loc4_ = _loc5_.next;
|
||||
_loc5_ = m_pairs[_loc4_];
|
||||
}
|
||||
if(_loc4_ == b2Pair.b2_nullPair)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
private function ValidateBuffer() : void
|
||||
{
|
||||
}
|
||||
|
||||
private function ValidateTable() : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Common.Math.b2XForm;
|
||||
|
||||
public class b2Point
|
||||
{
|
||||
|
||||
public var p:b2Vec2 = new b2Vec2();
|
||||
|
||||
public function b2Point()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function Support(param1:b2XForm, param2:Number, param3:Number) : b2Vec2
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
public function GetFirstVertex(param1:b2XForm) : b2Vec2
|
||||
{
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
public class b2Proxy
|
||||
{
|
||||
|
||||
public var lowerBounds:Array = [0,0];
|
||||
|
||||
public var upperBounds:Array = [0,0];
|
||||
|
||||
public var overlapCount:uint;
|
||||
|
||||
public var timeStamp:uint;
|
||||
|
||||
public var userData:* = null;
|
||||
|
||||
public function b2Proxy()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function GetNext() : uint
|
||||
{
|
||||
return lowerBounds[0];
|
||||
}
|
||||
|
||||
public function SetNext(param1:uint) : void
|
||||
{
|
||||
lowerBounds[0] = param1 & 0xFFFF;
|
||||
}
|
||||
|
||||
public function IsValid() : Boolean
|
||||
{
|
||||
return overlapCount != 65535;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
|
||||
public class b2Segment
|
||||
{
|
||||
|
||||
public var p1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var p2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public function b2Segment()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function TestSegment(param1:Array, param2:b2Vec2, param3:b2Segment, param4:Number) : Boolean
|
||||
{
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc12_:b2Vec2 = param3.p1;
|
||||
var _loc6_:Number = param3.p2.x - _loc12_.x;
|
||||
var _loc7_:Number = param3.p2.y - _loc12_.y;
|
||||
var _loc13_:Number = p2.x - p1.x;
|
||||
var _loc15_:Number;
|
||||
var _loc9_:Number = _loc15_ = p2.y - p1.y;
|
||||
var _loc10_:Number = -_loc13_;
|
||||
var _loc8_:Number = 100 * Number.MIN_VALUE;
|
||||
var _loc18_:Number = -(_loc6_ * _loc9_ + _loc7_ * _loc10_);
|
||||
if(_loc18_ > _loc8_)
|
||||
{
|
||||
_loc16_ = _loc12_.x - p1.x;
|
||||
_loc17_ = _loc12_.y - p1.y;
|
||||
_loc5_ = _loc16_ * _loc9_ + _loc17_ * _loc10_;
|
||||
if(0 <= _loc5_ && _loc5_ <= param4 * _loc18_)
|
||||
{
|
||||
_loc11_ = -_loc6_ * _loc17_ + _loc7_ * _loc16_;
|
||||
if(-_loc8_ * _loc18_ <= _loc11_ && _loc11_ <= _loc18_ * (1 + _loc8_))
|
||||
{
|
||||
_loc5_ /= _loc18_;
|
||||
_loc14_ = Math.sqrt(_loc9_ * _loc9_ + _loc10_ * _loc10_);
|
||||
_loc9_ /= _loc14_;
|
||||
_loc10_ /= _loc14_;
|
||||
param1[0] = _loc5_;
|
||||
param2.Set(_loc9_,_loc10_);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package Box2D.Collision
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Common.Math.b2Sweep;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Common.Math.b2XForm;
|
||||
|
||||
public class b2TimeOfImpact
|
||||
{
|
||||
|
||||
public static var s_p1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public static var s_p2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public static var s_xf1:b2XForm = new b2XForm();
|
||||
|
||||
public static var s_xf2:b2XForm = new b2XForm();
|
||||
|
||||
public function b2TimeOfImpact()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function TimeOfImpact(param1:b2Shape, param2:b2Sweep, param3:b2Shape, param4:b2Sweep) : Number
|
||||
{
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc26_:Number = NaN;
|
||||
var _loc10_:b2XForm = null;
|
||||
var _loc13_:b2XForm = null;
|
||||
var _loc27_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc25_:Number = NaN;
|
||||
var _loc24_:Number = NaN;
|
||||
var _loc30_:Number = param1.m_sweepRadius;
|
||||
var _loc5_:Number = param3.m_sweepRadius;
|
||||
var _loc28_:Number = param2.t0;
|
||||
var _loc29_:Number = param2.c.x - param2.c0.x;
|
||||
var _loc31_:Number = param2.c.y - param2.c0.y;
|
||||
var _loc18_:Number = param4.c.x - param4.c0.x;
|
||||
var _loc17_:Number = param4.c.y - param4.c0.y;
|
||||
var _loc21_:Number = param2.a - param2.a0;
|
||||
var _loc20_:Number = param4.a - param4.a0;
|
||||
var _loc16_:Number = 0;
|
||||
var _loc6_:b2Vec2 = s_p1;
|
||||
var _loc8_:b2Vec2 = s_p2;
|
||||
var _loc19_:int = 20;
|
||||
var _loc22_:int = 0;
|
||||
var _loc7_:Number = 0;
|
||||
var _loc9_:Number = 0;
|
||||
var _loc12_:Number = 0;
|
||||
var _loc23_:Number = 0;
|
||||
while(true)
|
||||
{
|
||||
_loc26_ = (1 - _loc16_) * _loc28_ + _loc16_;
|
||||
_loc10_ = s_xf1;
|
||||
_loc13_ = s_xf2;
|
||||
param2.GetXForm(_loc10_,_loc26_);
|
||||
param4.GetXForm(_loc13_,_loc26_);
|
||||
_loc12_ = b2Distance.Distance(_loc6_,_loc8_,param1,_loc10_,param3,_loc13_);
|
||||
if(_loc22_ == 0)
|
||||
{
|
||||
if(_loc12_ > 2 * 0.04)
|
||||
{
|
||||
_loc23_ = 1.5 * 0.04;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc11_ = 0.05 * 0.04;
|
||||
_loc14_ = _loc12_ - 0.5 * 0.04;
|
||||
_loc23_ = _loc11_ > _loc14_ ? _loc11_ : _loc14_;
|
||||
}
|
||||
}
|
||||
if(_loc12_ - _loc23_ < 0.05 * 0.04 || _loc22_ == _loc19_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc7_ = _loc8_.x - _loc6_.x;
|
||||
_loc9_ = _loc8_.y - _loc6_.y;
|
||||
_loc27_ = Math.sqrt(_loc7_ * _loc7_ + _loc9_ * _loc9_);
|
||||
_loc7_ /= _loc27_;
|
||||
_loc9_ /= _loc27_;
|
||||
_loc15_ = _loc7_ * (_loc29_ - _loc18_) + _loc9_ * (_loc31_ - _loc17_) + (_loc21_ < 0 ? -_loc21_ : _loc21_) * _loc30_ + (_loc20_ < 0 ? -_loc20_ : _loc20_) * _loc5_;
|
||||
if(_loc15_ == 0)
|
||||
{
|
||||
_loc16_ = 1;
|
||||
break;
|
||||
}
|
||||
_loc25_ = (_loc12_ - _loc23_) / _loc15_;
|
||||
_loc24_ = _loc16_ + _loc25_;
|
||||
if(_loc24_ < 0 || 1 < _loc24_)
|
||||
{
|
||||
_loc16_ = 1;
|
||||
break;
|
||||
}
|
||||
if(_loc24_ < (1 + 100 * Number.MIN_VALUE) * _loc16_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc16_ = _loc24_;
|
||||
_loc22_++;
|
||||
}
|
||||
return _loc16_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package Box2D.Common.Math
|
||||
{
|
||||
public class b2Mat22
|
||||
{
|
||||
|
||||
public var col1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var col2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public function b2Mat22(param1:Number = 0, param2:b2Vec2 = null, param3:b2Vec2 = null)
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
super();
|
||||
if(param2 != null && param3 != null)
|
||||
{
|
||||
col1.SetV(param2);
|
||||
col2.SetV(param3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = Math.cos(param1);
|
||||
_loc5_ = Math.sin(param1);
|
||||
col1.x = _loc4_;
|
||||
col2.x = -_loc5_;
|
||||
col1.y = _loc5_;
|
||||
col2.y = _loc4_;
|
||||
}
|
||||
}
|
||||
|
||||
public function Set(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = Math.cos(param1);
|
||||
var _loc3_:Number = Math.sin(param1);
|
||||
col1.x = _loc2_;
|
||||
col2.x = -_loc3_;
|
||||
col1.y = _loc3_;
|
||||
col2.y = _loc2_;
|
||||
}
|
||||
|
||||
public function SetVV(param1:b2Vec2, param2:b2Vec2) : void
|
||||
{
|
||||
col1.SetV(param1);
|
||||
col2.SetV(param2);
|
||||
}
|
||||
|
||||
public function Copy() : b2Mat22
|
||||
{
|
||||
return new b2Mat22(0,col1,col2);
|
||||
}
|
||||
|
||||
public function SetM(param1:b2Mat22) : void
|
||||
{
|
||||
col1.SetV(param1.col1);
|
||||
col2.SetV(param1.col2);
|
||||
}
|
||||
|
||||
public function AddM(param1:b2Mat22) : void
|
||||
{
|
||||
col1.x += param1.col1.x;
|
||||
col1.y += param1.col1.y;
|
||||
col2.x += param1.col2.x;
|
||||
col2.y += param1.col2.y;
|
||||
}
|
||||
|
||||
public function SetIdentity() : void
|
||||
{
|
||||
col1.x = 1;
|
||||
col2.x = 0;
|
||||
col1.y = 0;
|
||||
col2.y = 1;
|
||||
}
|
||||
|
||||
public function SetZero() : void
|
||||
{
|
||||
col1.x = 0;
|
||||
col2.x = 0;
|
||||
col1.y = 0;
|
||||
col2.y = 0;
|
||||
}
|
||||
|
||||
public function GetAngle() : Number
|
||||
{
|
||||
return Math.atan2(col1.y,col1.x);
|
||||
}
|
||||
|
||||
public function Invert(param1:b2Mat22) : b2Mat22
|
||||
{
|
||||
var _loc2_:Number = col1.x;
|
||||
var _loc3_:Number = col2.x;
|
||||
var _loc5_:Number = col1.y;
|
||||
var _loc6_:Number = col2.y;
|
||||
var _loc4_:Number = _loc2_ * _loc6_ - _loc3_ * _loc5_;
|
||||
_loc4_ = 1 / _loc4_;
|
||||
param1.col1.x = _loc4_ * _loc6_;
|
||||
param1.col2.x = -_loc4_ * _loc3_;
|
||||
param1.col1.y = -_loc4_ * _loc5_;
|
||||
param1.col2.y = _loc4_ * _loc2_;
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function Solve(param1:b2Vec2, param2:Number, param3:Number) : b2Vec2
|
||||
{
|
||||
var _loc4_:Number = col1.x;
|
||||
var _loc8_:Number = col2.x;
|
||||
var _loc6_:Number = col1.y;
|
||||
var _loc5_:Number = col2.y;
|
||||
var _loc7_:Number = _loc4_ * _loc5_ - _loc8_ * _loc6_;
|
||||
_loc7_ = 1 / _loc7_;
|
||||
param1.x = _loc7_ * (_loc5_ * param2 - _loc8_ * param3);
|
||||
param1.y = _loc7_ * (_loc4_ * param3 - _loc6_ * param2);
|
||||
return param1;
|
||||
}
|
||||
|
||||
public function Abs() : void
|
||||
{
|
||||
col1.Abs();
|
||||
col2.Abs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
package Box2D.Common.Math
|
||||
{
|
||||
public class b2Math
|
||||
{
|
||||
|
||||
public static const b2Vec2_zero:b2Vec2 = new b2Vec2(0,0);
|
||||
|
||||
public static const b2Mat22_identity:b2Mat22 = new b2Mat22(0,new b2Vec2(1,0),new b2Vec2(0,1));
|
||||
|
||||
public static const b2XForm_identity:b2XForm = new b2XForm(b2Vec2_zero,b2Mat22_identity);
|
||||
|
||||
public function b2Math()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function b2IsValid(param1:Number) : Boolean
|
||||
{
|
||||
return isFinite(param1);
|
||||
}
|
||||
|
||||
public static function b2Dot(param1:b2Vec2, param2:b2Vec2) : Number
|
||||
{
|
||||
return param1.x * param2.x + param1.y * param2.y;
|
||||
}
|
||||
|
||||
public static function b2CrossVV(param1:b2Vec2, param2:b2Vec2) : Number
|
||||
{
|
||||
return param1.x * param2.y - param1.y * param2.x;
|
||||
}
|
||||
|
||||
public static function b2CrossVF(param1:b2Vec2, param2:Number) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(param2 * param1.y,-param2 * param1.x);
|
||||
}
|
||||
|
||||
public static function b2CrossFV(param1:Number, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(-param1 * param2.y,param1 * param2.x);
|
||||
}
|
||||
|
||||
public static function b2MulMV(param1:b2Mat22, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(param1.col1.x * param2.x + param1.col2.x * param2.y,param1.col1.y * param2.x + param1.col2.y * param2.y);
|
||||
}
|
||||
|
||||
public static function b2MulTMV(param1:b2Mat22, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(b2Dot(param2,param1.col1),b2Dot(param2,param1.col2));
|
||||
}
|
||||
|
||||
public static function b2MulX(param1:b2XForm, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
var _loc3_:b2Vec2 = b2MulMV(param1.R,param2);
|
||||
_loc3_.x += param1.position.x;
|
||||
_loc3_.y += param1.position.y;
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function b2MulXT(param1:b2XForm, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
var _loc3_:b2Vec2 = SubtractVV(param2,param1.position);
|
||||
var _loc4_:Number = _loc3_.x * param1.R.col1.x + _loc3_.y * param1.R.col1.y;
|
||||
_loc3_.y = _loc3_.x * param1.R.col2.x + _loc3_.y * param1.R.col2.y;
|
||||
_loc3_.x = _loc4_;
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function AddVV(param1:b2Vec2, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(param1.x + param2.x,param1.y + param2.y);
|
||||
}
|
||||
|
||||
public static function SubtractVV(param1:b2Vec2, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(param1.x - param2.x,param1.y - param2.y);
|
||||
}
|
||||
|
||||
public static function b2Distance(param1:b2Vec2, param2:b2Vec2) : Number
|
||||
{
|
||||
var _loc3_:Number = param1.x - param2.x;
|
||||
var _loc4_:Number = param1.y - param2.y;
|
||||
return Math.sqrt(_loc3_ * _loc3_ + _loc4_ * _loc4_);
|
||||
}
|
||||
|
||||
public static function b2DistanceSquared(param1:b2Vec2, param2:b2Vec2) : Number
|
||||
{
|
||||
var _loc3_:Number = param1.x - param2.x;
|
||||
var _loc4_:Number = param1.y - param2.y;
|
||||
return _loc3_ * _loc3_ + _loc4_ * _loc4_;
|
||||
}
|
||||
|
||||
public static function MulFV(param1:Number, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(param1 * param2.x,param1 * param2.y);
|
||||
}
|
||||
|
||||
public static function AddMM(param1:b2Mat22, param2:b2Mat22) : b2Mat22
|
||||
{
|
||||
return new b2Mat22(0,AddVV(param1.col1,param2.col1),AddVV(param1.col2,param2.col2));
|
||||
}
|
||||
|
||||
public static function b2MulMM(param1:b2Mat22, param2:b2Mat22) : b2Mat22
|
||||
{
|
||||
return new b2Mat22(0,b2MulMV(param1,param2.col1),b2MulMV(param1,param2.col2));
|
||||
}
|
||||
|
||||
public static function b2MulTMM(param1:b2Mat22, param2:b2Mat22) : b2Mat22
|
||||
{
|
||||
var _loc4_:b2Vec2 = new b2Vec2(b2Dot(param1.col1,param2.col1),b2Dot(param1.col2,param2.col1));
|
||||
var _loc5_:b2Vec2 = new b2Vec2(b2Dot(param1.col1,param2.col2),b2Dot(param1.col2,param2.col2));
|
||||
return new b2Mat22(0,_loc4_,_loc5_);
|
||||
}
|
||||
|
||||
public static function b2Abs(param1:Number) : Number
|
||||
{
|
||||
return param1 > 0 ? param1 : -param1;
|
||||
}
|
||||
|
||||
public static function b2AbsV(param1:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(b2Abs(param1.x),b2Abs(param1.y));
|
||||
}
|
||||
|
||||
public static function b2AbsM(param1:b2Mat22) : b2Mat22
|
||||
{
|
||||
return new b2Mat22(0,b2AbsV(param1.col1),b2AbsV(param1.col2));
|
||||
}
|
||||
|
||||
public static function b2Min(param1:Number, param2:Number) : Number
|
||||
{
|
||||
return param1 < param2 ? param1 : param2;
|
||||
}
|
||||
|
||||
public static function b2MinV(param1:b2Vec2, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(b2Min(param1.x,param2.x),b2Min(param1.y,param2.y));
|
||||
}
|
||||
|
||||
public static function b2Max(param1:Number, param2:Number) : Number
|
||||
{
|
||||
return param1 > param2 ? param1 : param2;
|
||||
}
|
||||
|
||||
public static function b2MaxV(param1:b2Vec2, param2:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(b2Max(param1.x,param2.x),b2Max(param1.y,param2.y));
|
||||
}
|
||||
|
||||
public static function b2Clamp(param1:Number, param2:Number, param3:Number) : Number
|
||||
{
|
||||
return b2Max(param2,b2Min(param1,param3));
|
||||
}
|
||||
|
||||
public static function b2ClampV(param1:b2Vec2, param2:b2Vec2, param3:b2Vec2) : b2Vec2
|
||||
{
|
||||
return b2MaxV(param2,b2MinV(param1,param3));
|
||||
}
|
||||
|
||||
public static function b2Swap(param1:Array, param2:Array) : void
|
||||
{
|
||||
var _loc3_:* = param1[0];
|
||||
param1[0] = param2[0];
|
||||
param2[0] = _loc3_;
|
||||
}
|
||||
|
||||
public static function b2Random() : Number
|
||||
{
|
||||
return Math.random() * 2 - 1;
|
||||
}
|
||||
|
||||
public static function b2RandomRange(param1:Number, param2:Number) : Number
|
||||
{
|
||||
var _loc3_:Number = Math.random();
|
||||
return (param2 - param1) * _loc3_ + param1;
|
||||
}
|
||||
|
||||
public static function b2NextPowerOfTwo(param1:uint) : uint
|
||||
{
|
||||
param1 |= param1 >> 1 & 0x7FFFFFFF;
|
||||
param1 |= param1 >> 2 & 0x3FFFFFFF;
|
||||
param1 |= param1 >> 4 & 0x0FFFFFFF;
|
||||
param1 |= param1 >> 8 & 0xFFFFFF;
|
||||
param1 |= param1 >> 16 & 0xFFFF;
|
||||
return param1 + 1;
|
||||
}
|
||||
|
||||
public static function b2IsPowerOfTwo(param1:uint) : Boolean
|
||||
{
|
||||
return param1 > 0 && (param1 & param1 - 1) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package Box2D.Common.Math
|
||||
{
|
||||
public class b2Sweep
|
||||
{
|
||||
|
||||
public var localCenter:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var c0:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var c:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var a0:Number;
|
||||
|
||||
public var a:Number;
|
||||
|
||||
public var t0:Number;
|
||||
|
||||
public function b2Sweep()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function GetXForm(param1:b2XForm, param2:Number) : void
|
||||
{
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
if(1 - t0 > Number.MIN_VALUE)
|
||||
{
|
||||
_loc3_ = (param2 - t0) / (1 - t0);
|
||||
param1.position.x = (1 - _loc3_) * c0.x + _loc3_ * c.x;
|
||||
param1.position.y = (1 - _loc3_) * c0.y + _loc3_ * c.y;
|
||||
_loc4_ = (1 - _loc3_) * a0 + _loc3_ * a;
|
||||
param1.R.Set(_loc4_);
|
||||
}
|
||||
else
|
||||
{
|
||||
param1.position.SetV(c);
|
||||
param1.R.Set(a);
|
||||
}
|
||||
var _loc5_:b2Mat22 = param1.R;
|
||||
param1.position.x -= _loc5_.col1.x * localCenter.x + _loc5_.col2.x * localCenter.y;
|
||||
param1.position.y -= _loc5_.col1.y * localCenter.x + _loc5_.col2.y * localCenter.y;
|
||||
}
|
||||
|
||||
public function Advance(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = NaN;
|
||||
if(t0 < param1 && 1 - t0 > Number.MIN_VALUE)
|
||||
{
|
||||
_loc2_ = (param1 - t0) / (1 - t0);
|
||||
c0.x = (1 - _loc2_) * c0.x + _loc2_ * c.x;
|
||||
c0.y = (1 - _loc2_) * c0.y + _loc2_ * c.y;
|
||||
a0 = (1 - _loc2_) * a0 + _loc2_ * a;
|
||||
t0 = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package Box2D.Common.Math
|
||||
{
|
||||
public class b2Vec2
|
||||
{
|
||||
|
||||
public var x:Number;
|
||||
|
||||
public var y:Number;
|
||||
|
||||
public function b2Vec2(param1:Number = 0, param2:Number = 0)
|
||||
{
|
||||
super();
|
||||
x = param1;
|
||||
y = param2;
|
||||
}
|
||||
|
||||
public static function Make(param1:Number, param2:Number) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(param1,param2);
|
||||
}
|
||||
|
||||
public function SetZero() : void
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
public function Set(param1:Number = 0, param2:Number = 0) : void
|
||||
{
|
||||
x = param1;
|
||||
y = param2;
|
||||
}
|
||||
|
||||
public function SetV(param1:b2Vec2) : void
|
||||
{
|
||||
x = param1.x;
|
||||
y = param1.y;
|
||||
}
|
||||
|
||||
public function Negative() : b2Vec2
|
||||
{
|
||||
return new b2Vec2(-x,-y);
|
||||
}
|
||||
|
||||
public function Copy() : b2Vec2
|
||||
{
|
||||
return new b2Vec2(x,y);
|
||||
}
|
||||
|
||||
public function Add(param1:b2Vec2) : void
|
||||
{
|
||||
x += param1.x;
|
||||
y += param1.y;
|
||||
}
|
||||
|
||||
public function Subtract(param1:b2Vec2) : void
|
||||
{
|
||||
x -= param1.x;
|
||||
y -= param1.y;
|
||||
}
|
||||
|
||||
public function Multiply(param1:Number) : void
|
||||
{
|
||||
x *= param1;
|
||||
y *= param1;
|
||||
}
|
||||
|
||||
public function MulM(param1:b2Mat22) : void
|
||||
{
|
||||
var _loc2_:Number = x;
|
||||
x = param1.col1.x * _loc2_ + param1.col2.x * y;
|
||||
y = param1.col1.y * _loc2_ + param1.col2.y * y;
|
||||
}
|
||||
|
||||
public function MulTM(param1:b2Mat22) : void
|
||||
{
|
||||
var _loc2_:Number = b2Math.b2Dot(this,param1.col1);
|
||||
y = b2Math.b2Dot(this,param1.col2);
|
||||
x = _loc2_;
|
||||
}
|
||||
|
||||
public function CrossVF(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = x;
|
||||
x = param1 * y;
|
||||
y = -param1 * _loc2_;
|
||||
}
|
||||
|
||||
public function CrossFV(param1:Number) : void
|
||||
{
|
||||
var _loc2_:Number = x;
|
||||
x = -param1 * y;
|
||||
y = param1 * _loc2_;
|
||||
}
|
||||
|
||||
public function MinV(param1:b2Vec2) : void
|
||||
{
|
||||
x = x < param1.x ? x : param1.x;
|
||||
y = y < param1.y ? y : param1.y;
|
||||
}
|
||||
|
||||
public function MaxV(param1:b2Vec2) : void
|
||||
{
|
||||
x = x > param1.x ? x : param1.x;
|
||||
y = y > param1.y ? y : param1.y;
|
||||
}
|
||||
|
||||
public function Abs() : void
|
||||
{
|
||||
if(x < 0)
|
||||
{
|
||||
x = -x;
|
||||
}
|
||||
if(y < 0)
|
||||
{
|
||||
y = -y;
|
||||
}
|
||||
}
|
||||
|
||||
public function Length() : Number
|
||||
{
|
||||
return Math.sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
public function LengthSquared() : Number
|
||||
{
|
||||
return x * x + y * y;
|
||||
}
|
||||
|
||||
public function Normalize() : Number
|
||||
{
|
||||
var _loc2_:Number = Math.sqrt(x * x + y * y);
|
||||
if(_loc2_ < Number.MIN_VALUE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var _loc1_:Number = 1 / _loc2_;
|
||||
x *= _loc1_;
|
||||
y *= _loc1_;
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function IsValid() : Boolean
|
||||
{
|
||||
return b2Math.b2IsValid(x) && b2Math.b2IsValid(y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package Box2D.Common.Math
|
||||
{
|
||||
public class b2XForm
|
||||
{
|
||||
|
||||
public var position:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var R:b2Mat22 = new b2Mat22();
|
||||
|
||||
public function b2XForm(param1:b2Vec2 = null, param2:b2Mat22 = null)
|
||||
{
|
||||
super();
|
||||
if(param1)
|
||||
{
|
||||
position.SetV(param1);
|
||||
R.SetM(param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function Initialize(param1:b2Vec2, param2:b2Mat22) : void
|
||||
{
|
||||
position.SetV(param1);
|
||||
R.SetM(param2);
|
||||
}
|
||||
|
||||
public function SetIdentity() : void
|
||||
{
|
||||
position.SetZero();
|
||||
R.SetIdentity();
|
||||
}
|
||||
|
||||
public function Set(param1:b2XForm) : void
|
||||
{
|
||||
position.SetV(param1.position);
|
||||
R.SetM(param1.R);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package Box2D.Common
|
||||
{
|
||||
import Box2D.Common.Math.b2Math;
|
||||
|
||||
public class b2Color
|
||||
{
|
||||
|
||||
private var _r:uint = 0;
|
||||
|
||||
private var _g:uint = 0;
|
||||
|
||||
private var _b:uint = 0;
|
||||
|
||||
public function b2Color(param1:Number, param2:Number, param3:Number)
|
||||
{
|
||||
super();
|
||||
_r = 255 * b2Math.b2Clamp(param1,0,1);
|
||||
_g = 255 * b2Math.b2Clamp(param2,0,1);
|
||||
_b = 255 * b2Math.b2Clamp(param3,0,1);
|
||||
}
|
||||
|
||||
public function Set(param1:Number, param2:Number, param3:Number) : void
|
||||
{
|
||||
_r = 255 * b2Math.b2Clamp(param1,0,1);
|
||||
_g = 255 * b2Math.b2Clamp(param2,0,1);
|
||||
_b = 255 * b2Math.b2Clamp(param3,0,1);
|
||||
}
|
||||
|
||||
public function set r(param1:Number) : void
|
||||
{
|
||||
_r = 255 * b2Math.b2Clamp(param1,0,1);
|
||||
}
|
||||
|
||||
public function set g(param1:Number) : void
|
||||
{
|
||||
_g = 255 * b2Math.b2Clamp(param1,0,1);
|
||||
}
|
||||
|
||||
public function set b(param1:Number) : void
|
||||
{
|
||||
_b = 255 * b2Math.b2Clamp(param1,0,1);
|
||||
}
|
||||
|
||||
public function get color() : uint
|
||||
{
|
||||
return _r | _g << 8 | _b << 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package Box2D.Common
|
||||
{
|
||||
public class b2Settings
|
||||
{
|
||||
|
||||
public static const USHRT_MAX:int = 65535;
|
||||
|
||||
public static const b2_pi:Number = 3.141592653589793;
|
||||
|
||||
public static const b2_maxManifoldPoints:int = 2;
|
||||
|
||||
public static const b2_maxPolygonVertices:int = 8;
|
||||
|
||||
public static const b2_maxProxies:int = 512;
|
||||
|
||||
public static const b2_maxPairs:int = 4096;
|
||||
|
||||
public static const b2_linearSlop:Number = 0.005;
|
||||
|
||||
public static const b2_angularSlop:Number = 0.03490658503988659;
|
||||
|
||||
public static const b2_toiSlop:Number = 0.04;
|
||||
|
||||
public static const b2_maxTOIContactsPerIsland:int = 32;
|
||||
|
||||
public static const b2_velocityThreshold:Number = 1;
|
||||
|
||||
public static const b2_maxLinearCorrection:Number = 0.2;
|
||||
|
||||
public static const b2_maxAngularCorrection:Number = 0.13962634015954636;
|
||||
|
||||
public static const b2_maxLinearVelocity:Number = 200;
|
||||
|
||||
public static const b2_maxLinearVelocitySquared:Number = 40000;
|
||||
|
||||
public static const b2_maxAngularVelocity:Number = 250;
|
||||
|
||||
public static const b2_maxAngularVelocitySquared:Number = 62500;
|
||||
|
||||
public static const b2_contactBaumgarte:Number = 0.2;
|
||||
|
||||
public static const b2_timeToSleep:Number = 0.5;
|
||||
|
||||
public static const b2_linearSleepTolerance:Number = 0.01;
|
||||
|
||||
public static const b2_angularSleepTolerance:Number = 0.011111111111111112;
|
||||
|
||||
public function b2Settings()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function b2Assert(param1:Boolean) : void
|
||||
{
|
||||
var _loc2_:* = null;
|
||||
if(!param1)
|
||||
{
|
||||
_loc2_.x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Collision.Shapes.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.*;
|
||||
|
||||
public class b2CircleContact extends b2Contact
|
||||
{
|
||||
|
||||
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
|
||||
|
||||
private var m_manifolds:Array = [new b2Manifold()];
|
||||
|
||||
public var m_manifold:b2Manifold;
|
||||
|
||||
private var m0:b2Manifold = new b2Manifold();
|
||||
|
||||
public function b2CircleContact(param1:b2Shape, param2:b2Shape)
|
||||
{
|
||||
super(param1,param2);
|
||||
m_manifold = m_manifolds[0];
|
||||
m_manifold.pointCount = 0;
|
||||
var _loc3_:b2ManifoldPoint = m_manifold.points[0];
|
||||
_loc3_.normalImpulse = 0;
|
||||
_loc3_.tangentImpulse = 0;
|
||||
}
|
||||
|
||||
public static function Create(param1:b2Shape, param2:b2Shape, param3:*) : b2Contact
|
||||
{
|
||||
return new b2CircleContact(param1,param2);
|
||||
}
|
||||
|
||||
public static function Destroy(param1:b2Contact, param2:*) : void
|
||||
{
|
||||
}
|
||||
|
||||
override public function Evaluate(param1:b2ContactListener) : void
|
||||
{
|
||||
var _loc4_:b2Vec2 = null;
|
||||
var _loc5_:b2Vec2 = null;
|
||||
var _loc6_:b2ManifoldPoint = null;
|
||||
var _loc3_:b2ManifoldPoint = null;
|
||||
var _loc8_:b2Body = m_shape1.m_body;
|
||||
var _loc2_:b2Body = m_shape2.m_body;
|
||||
m0.Set(m_manifold);
|
||||
b2Collision.b2CollideCircles(m_manifold,m_shape1 as b2CircleShape,_loc8_.m_xf,m_shape2 as b2CircleShape,_loc2_.m_xf);
|
||||
var _loc7_:b2ContactPoint = s_evalCP;
|
||||
_loc7_.shape1 = m_shape1;
|
||||
_loc7_.shape2 = m_shape2;
|
||||
_loc7_.friction = m_friction;
|
||||
_loc7_.restitution = m_restitution;
|
||||
if(m_manifold.pointCount > 0)
|
||||
{
|
||||
m_manifoldCount = 1;
|
||||
_loc3_ = m_manifold.points[0];
|
||||
if(m0.pointCount == 0)
|
||||
{
|
||||
_loc3_.normalImpulse = 0;
|
||||
_loc3_.tangentImpulse = 0;
|
||||
if(param1)
|
||||
{
|
||||
_loc7_.position = _loc8_.GetWorldPoint(_loc3_.localPoint1);
|
||||
_loc4_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc3_.localPoint1);
|
||||
_loc5_ = _loc2_.GetLinearVelocityFromLocalPoint(_loc3_.localPoint2);
|
||||
_loc7_.velocity.Set(_loc5_.x - _loc4_.x,_loc5_.y - _loc4_.y);
|
||||
_loc7_.normal.SetV(m_manifold.normal);
|
||||
_loc7_.separation = _loc3_.separation;
|
||||
_loc7_.id.key = _loc3_.id._key;
|
||||
param1.Add(_loc7_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = m0.points[0];
|
||||
_loc3_.normalImpulse = _loc6_.normalImpulse;
|
||||
_loc3_.tangentImpulse = _loc6_.tangentImpulse;
|
||||
if(param1)
|
||||
{
|
||||
_loc7_.position = _loc8_.GetWorldPoint(_loc3_.localPoint1);
|
||||
_loc4_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc3_.localPoint1);
|
||||
_loc5_ = _loc2_.GetLinearVelocityFromLocalPoint(_loc3_.localPoint2);
|
||||
_loc7_.velocity.Set(_loc5_.x - _loc4_.x,_loc5_.y - _loc4_.y);
|
||||
_loc7_.normal.SetV(m_manifold.normal);
|
||||
_loc7_.separation = _loc3_.separation;
|
||||
_loc7_.id.key = _loc3_.id._key;
|
||||
param1.Persist(_loc7_);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_manifoldCount = 0;
|
||||
if(m0.pointCount > 0 && param1)
|
||||
{
|
||||
_loc6_ = m0.points[0];
|
||||
_loc7_.position = _loc8_.GetWorldPoint(_loc6_.localPoint1);
|
||||
_loc4_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc6_.localPoint1);
|
||||
_loc5_ = _loc2_.GetLinearVelocityFromLocalPoint(_loc6_.localPoint2);
|
||||
_loc7_.velocity.Set(_loc5_.x - _loc4_.x,_loc5_.y - _loc4_.y);
|
||||
_loc7_.normal.SetV(m0.normal);
|
||||
_loc7_.separation = _loc6_.separation;
|
||||
_loc7_.id.key = _loc6_.id._key;
|
||||
param1.Remove(_loc7_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override public function GetManifolds() : Array
|
||||
{
|
||||
return m_manifolds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Collision.Shapes.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.*;
|
||||
|
||||
public class b2Contact
|
||||
{
|
||||
|
||||
public static var e_nonSolidFlag:uint = 1;
|
||||
|
||||
public static var e_slowFlag:uint = 2;
|
||||
|
||||
public static var e_islandFlag:uint = 4;
|
||||
|
||||
public static var e_toiFlag:uint = 8;
|
||||
|
||||
public static var s_registers:Array;
|
||||
|
||||
public static var s_initialized:Boolean = false;
|
||||
|
||||
public var m_flags:uint;
|
||||
|
||||
public var m_prev:b2Contact;
|
||||
|
||||
public var m_next:b2Contact;
|
||||
|
||||
public var m_node1:b2ContactEdge = new b2ContactEdge();
|
||||
|
||||
public var m_node2:b2ContactEdge = new b2ContactEdge();
|
||||
|
||||
public var m_shape1:b2Shape;
|
||||
|
||||
public var m_shape2:b2Shape;
|
||||
|
||||
public var m_manifoldCount:int;
|
||||
|
||||
public var m_friction:Number;
|
||||
|
||||
public var m_restitution:Number;
|
||||
|
||||
public var m_toi:Number;
|
||||
|
||||
public function b2Contact(param1:b2Shape = null, param2:b2Shape = null)
|
||||
{
|
||||
super();
|
||||
m_flags = 0;
|
||||
if(!param1 || !param2)
|
||||
{
|
||||
m_shape1 = null;
|
||||
m_shape2 = null;
|
||||
return;
|
||||
}
|
||||
if(param1.IsSensor() || param2.IsSensor())
|
||||
{
|
||||
m_flags |= e_nonSolidFlag;
|
||||
}
|
||||
m_shape1 = param1;
|
||||
m_shape2 = param2;
|
||||
m_manifoldCount = 0;
|
||||
m_friction = Math.sqrt(m_shape1.m_friction * m_shape2.m_friction);
|
||||
m_restitution = b2Math.b2Max(m_shape1.m_restitution,m_shape2.m_restitution);
|
||||
m_prev = null;
|
||||
m_next = null;
|
||||
m_node1.contact = null;
|
||||
m_node1.prev = null;
|
||||
m_node1.next = null;
|
||||
m_node1.other = null;
|
||||
m_node2.contact = null;
|
||||
m_node2.prev = null;
|
||||
m_node2.next = null;
|
||||
m_node2.other = null;
|
||||
}
|
||||
|
||||
public static function AddType(param1:Function, param2:Function, param3:int, param4:int) : void
|
||||
{
|
||||
s_registers[param3][param4].createFcn = param1;
|
||||
s_registers[param3][param4].destroyFcn = param2;
|
||||
s_registers[param3][param4].primary = true;
|
||||
if(param3 != param4)
|
||||
{
|
||||
s_registers[param4][param3].createFcn = param1;
|
||||
s_registers[param4][param3].destroyFcn = param2;
|
||||
s_registers[param4][param3].primary = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function InitializeRegisters() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
s_registers = new Array(2);
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 2)
|
||||
{
|
||||
s_registers[_loc1_] = new Array(2);
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 2)
|
||||
{
|
||||
s_registers[_loc1_][_loc2_] = new b2ContactRegister();
|
||||
_loc2_++;
|
||||
}
|
||||
_loc1_++;
|
||||
}
|
||||
AddType(b2CircleContact.Create,b2CircleContact.Destroy,0,0);
|
||||
AddType(b2PolyAndCircleContact.Create,b2PolyAndCircleContact.Destroy,1,0);
|
||||
AddType(b2PolygonContact.Create,b2PolygonContact.Destroy,1,1);
|
||||
}
|
||||
|
||||
public static function Create(param1:b2Shape, param2:b2Shape, param3:*) : b2Contact
|
||||
{
|
||||
var _loc5_:b2Contact = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc9_:b2Manifold = null;
|
||||
if(s_initialized == false)
|
||||
{
|
||||
InitializeRegisters();
|
||||
s_initialized = true;
|
||||
}
|
||||
var _loc8_:int = param1.m_type;
|
||||
var _loc4_:int = param2.m_type;
|
||||
var _loc6_:b2ContactRegister = s_registers[_loc8_][_loc4_];
|
||||
var _loc10_:Function = _loc6_.createFcn;
|
||||
if(_loc10_ != null)
|
||||
{
|
||||
if(_loc6_.primary)
|
||||
{
|
||||
return _loc10_(param1,param2,param3);
|
||||
}
|
||||
_loc5_ = _loc10_(param2,param1,param3);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc5_.m_manifoldCount)
|
||||
{
|
||||
_loc9_ = _loc5_.GetManifolds()[_loc7_];
|
||||
_loc9_.normal = _loc9_.normal.Negative();
|
||||
_loc7_++;
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function Destroy(param1:b2Contact, param2:*) : void
|
||||
{
|
||||
if(param1.m_manifoldCount > 0)
|
||||
{
|
||||
param1.m_shape1.m_body.WakeUp();
|
||||
param1.m_shape2.m_body.WakeUp();
|
||||
}
|
||||
var _loc6_:int = param1.m_shape1.m_type;
|
||||
var _loc4_:int = param1.m_shape2.m_type;
|
||||
var _loc5_:b2ContactRegister = s_registers[_loc6_][_loc4_];
|
||||
var _loc3_:Function = _loc5_.destroyFcn;
|
||||
_loc3_(param1,param2);
|
||||
}
|
||||
|
||||
public function GetManifolds() : Array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetManifoldCount() : int
|
||||
{
|
||||
return m_manifoldCount;
|
||||
}
|
||||
|
||||
public function IsSolid() : Boolean
|
||||
{
|
||||
return (m_flags & e_nonSolidFlag) == 0;
|
||||
}
|
||||
|
||||
public function GetNext() : b2Contact
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
public function GetShape1() : b2Shape
|
||||
{
|
||||
return m_shape1;
|
||||
}
|
||||
|
||||
public function GetShape2() : b2Shape
|
||||
{
|
||||
return m_shape2;
|
||||
}
|
||||
|
||||
public function Update(param1:b2ContactListener) : void
|
||||
{
|
||||
var _loc2_:int = m_manifoldCount;
|
||||
Evaluate(param1);
|
||||
var _loc3_:int = m_manifoldCount;
|
||||
var _loc4_:b2Body = m_shape1.m_body;
|
||||
var _loc5_:b2Body = m_shape2.m_body;
|
||||
if(_loc3_ == 0 && _loc2_ > 0)
|
||||
{
|
||||
_loc4_.WakeUp();
|
||||
_loc5_.WakeUp();
|
||||
}
|
||||
if(_loc4_.IsStatic() || _loc4_.IsBullet() || _loc5_.IsStatic() || _loc5_.IsBullet())
|
||||
{
|
||||
m_flags &= ~e_slowFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flags |= e_slowFlag;
|
||||
}
|
||||
}
|
||||
|
||||
public function Evaluate(param1:b2ContactListener) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.*;
|
||||
|
||||
public class b2ContactConstraint
|
||||
{
|
||||
|
||||
public var points:Array;
|
||||
|
||||
public var normal:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var manifold:b2Manifold;
|
||||
|
||||
public var body1:b2Body;
|
||||
|
||||
public var body2:b2Body;
|
||||
|
||||
public var friction:Number;
|
||||
|
||||
public var restitution:Number;
|
||||
|
||||
public var pointCount:int;
|
||||
|
||||
public function b2ContactConstraint()
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
super();
|
||||
points = new Array(2);
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < 2)
|
||||
{
|
||||
points[_loc1_] = new b2ContactConstraintPoint();
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2ContactConstraintPoint
|
||||
{
|
||||
|
||||
public var localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var r1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var r2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var normalImpulse:Number;
|
||||
|
||||
public var tangentImpulse:Number;
|
||||
|
||||
public var positionImpulse:Number;
|
||||
|
||||
public var normalMass:Number;
|
||||
|
||||
public var tangentMass:Number;
|
||||
|
||||
public var equalizedMass:Number;
|
||||
|
||||
public var separation:Number;
|
||||
|
||||
public var velocityBias:Number;
|
||||
|
||||
public function b2ContactConstraintPoint()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Dynamics.b2Body;
|
||||
|
||||
public class b2ContactEdge
|
||||
{
|
||||
|
||||
public var other:b2Body;
|
||||
|
||||
public var contact:b2Contact;
|
||||
|
||||
public var prev:b2ContactEdge;
|
||||
|
||||
public var next:b2ContactEdge;
|
||||
|
||||
public function b2ContactEdge()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
public class b2ContactRegister
|
||||
{
|
||||
|
||||
public var createFcn:Function;
|
||||
|
||||
public var destroyFcn:Function;
|
||||
|
||||
public var primary:Boolean;
|
||||
|
||||
public function b2ContactRegister()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Collision.b2ContactID;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2ContactResult
|
||||
{
|
||||
|
||||
public var shape1:b2Shape;
|
||||
|
||||
public var shape2:b2Shape;
|
||||
|
||||
public var position:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var normal:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var normalImpulse:Number;
|
||||
|
||||
public var tangentImpulse:Number;
|
||||
|
||||
public var id:b2ContactID = new b2ContactID();
|
||||
|
||||
public function b2ContactResult()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,475 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.*;
|
||||
|
||||
public class b2ContactSolver
|
||||
{
|
||||
|
||||
public var m_step:b2TimeStep = new b2TimeStep();
|
||||
|
||||
public var m_allocator:*;
|
||||
|
||||
public var m_constraints:Array = [];
|
||||
|
||||
public var m_constraintCount:int;
|
||||
|
||||
public function b2ContactSolver(param1:b2TimeStep, param2:Array, param3:int, param4:*)
|
||||
{
|
||||
var _loc14_:b2Contact = null;
|
||||
var _loc28_:int = 0;
|
||||
var _loc40_:* = null;
|
||||
var _loc44_:b2Mat22 = null;
|
||||
var _loc9_:b2Body = null;
|
||||
var _loc10_:b2Body = null;
|
||||
var _loc11_:int = 0;
|
||||
var _loc6_:Array = null;
|
||||
var _loc33_:Number = NaN;
|
||||
var _loc37_:Number = NaN;
|
||||
var _loc46_:Number = NaN;
|
||||
var _loc47_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc29_:int = 0;
|
||||
var _loc16_:b2Manifold = null;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc23_:b2ContactConstraint = null;
|
||||
var _loc31_:* = 0;
|
||||
var _loc32_:b2ManifoldPoint = null;
|
||||
var _loc12_:b2ContactConstraintPoint = null;
|
||||
var _loc24_:Number = NaN;
|
||||
var _loc25_:Number = NaN;
|
||||
var _loc43_:Number = NaN;
|
||||
var _loc45_:Number = NaN;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc30_:Number = NaN;
|
||||
var _loc38_:Number = NaN;
|
||||
var _loc41_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc36_:Number = NaN;
|
||||
var _loc26_:Number = NaN;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc34_:Number = NaN;
|
||||
var _loc35_:Number = NaN;
|
||||
var _loc42_:Number = NaN;
|
||||
var _loc39_:Number = NaN;
|
||||
super();
|
||||
m_step.dt = param1.dt;
|
||||
m_step.inv_dt = param1.inv_dt;
|
||||
m_step.maxIterations = param1.maxIterations;
|
||||
m_allocator = param4;
|
||||
m_constraintCount = 0;
|
||||
_loc28_ = 0;
|
||||
while(_loc28_ < param3)
|
||||
{
|
||||
_loc14_ = param2[_loc28_];
|
||||
m_constraintCount += _loc14_.m_manifoldCount;
|
||||
_loc28_++;
|
||||
}
|
||||
_loc28_ = 0;
|
||||
while(_loc28_ < m_constraintCount)
|
||||
{
|
||||
m_constraints[_loc28_] = new b2ContactConstraint();
|
||||
_loc28_++;
|
||||
}
|
||||
var _loc27_:int = 0;
|
||||
_loc28_ = 0;
|
||||
while(_loc28_ < param3)
|
||||
{
|
||||
_loc14_ = param2[_loc28_];
|
||||
_loc9_ = _loc14_.m_shape1.m_body;
|
||||
_loc10_ = _loc14_.m_shape2.m_body;
|
||||
_loc11_ = _loc14_.m_manifoldCount;
|
||||
_loc6_ = _loc14_.GetManifolds();
|
||||
_loc33_ = _loc14_.m_friction;
|
||||
_loc37_ = _loc14_.m_restitution;
|
||||
_loc46_ = _loc9_.m_linearVelocity.x;
|
||||
_loc47_ = _loc9_.m_linearVelocity.y;
|
||||
_loc21_ = _loc10_.m_linearVelocity.x;
|
||||
_loc20_ = _loc10_.m_linearVelocity.y;
|
||||
_loc18_ = _loc9_.m_angularVelocity;
|
||||
_loc19_ = _loc10_.m_angularVelocity;
|
||||
_loc29_ = 0;
|
||||
while(_loc29_ < _loc11_)
|
||||
{
|
||||
_loc16_ = _loc6_[_loc29_];
|
||||
_loc5_ = _loc16_.normal.x;
|
||||
_loc7_ = _loc16_.normal.y;
|
||||
_loc23_ = m_constraints[_loc27_];
|
||||
_loc23_.body1 = _loc9_;
|
||||
_loc23_.body2 = _loc10_;
|
||||
_loc23_.manifold = _loc16_;
|
||||
_loc23_.normal.x = _loc5_;
|
||||
_loc23_.normal.y = _loc7_;
|
||||
_loc23_.pointCount = _loc16_.pointCount;
|
||||
_loc23_.friction = _loc33_;
|
||||
_loc23_.restitution = _loc37_;
|
||||
_loc31_ = 0;
|
||||
while(_loc31_ < _loc23_.pointCount)
|
||||
{
|
||||
_loc32_ = _loc16_.points[_loc31_];
|
||||
_loc12_ = _loc23_.points[_loc31_];
|
||||
_loc12_.normalImpulse = _loc32_.normalImpulse;
|
||||
_loc12_.tangentImpulse = _loc32_.tangentImpulse;
|
||||
_loc12_.separation = _loc32_.separation;
|
||||
_loc12_.positionImpulse = 0;
|
||||
_loc12_.localAnchor1.SetV(_loc32_.localPoint1);
|
||||
_loc12_.localAnchor2.SetV(_loc32_.localPoint2);
|
||||
_loc44_ = _loc9_.m_xf.R;
|
||||
_loc43_ = _loc32_.localPoint1.x - _loc9_.m_sweep.localCenter.x;
|
||||
_loc45_ = _loc32_.localPoint1.y - _loc9_.m_sweep.localCenter.y;
|
||||
_loc24_ = _loc44_.col1.x * _loc43_ + _loc44_.col2.x * _loc45_;
|
||||
_loc45_ = _loc44_.col1.y * _loc43_ + _loc44_.col2.y * _loc45_;
|
||||
_loc43_ = _loc24_;
|
||||
_loc12_.r1.Set(_loc43_,_loc45_);
|
||||
_loc44_ = _loc10_.m_xf.R;
|
||||
_loc17_ = _loc32_.localPoint2.x - _loc10_.m_sweep.localCenter.x;
|
||||
_loc15_ = _loc32_.localPoint2.y - _loc10_.m_sweep.localCenter.y;
|
||||
_loc24_ = _loc44_.col1.x * _loc17_ + _loc44_.col2.x * _loc15_;
|
||||
_loc15_ = _loc44_.col1.y * _loc17_ + _loc44_.col2.y * _loc15_;
|
||||
_loc17_ = _loc24_;
|
||||
_loc12_.r2.Set(_loc17_,_loc15_);
|
||||
_loc8_ = _loc43_ * _loc43_ + _loc45_ * _loc45_;
|
||||
_loc30_ = _loc17_ * _loc17_ + _loc15_ * _loc15_;
|
||||
_loc38_ = _loc43_ * _loc5_ + _loc45_ * _loc7_;
|
||||
_loc41_ = _loc17_ * _loc5_ + _loc15_ * _loc7_;
|
||||
_loc13_ = _loc9_.m_invMass + _loc10_.m_invMass;
|
||||
_loc13_ = _loc13_ + (_loc9_.m_invI * (_loc8_ - _loc38_ * _loc38_) + _loc10_.m_invI * (_loc30_ - _loc41_ * _loc41_));
|
||||
_loc12_.normalMass = 1 / _loc13_;
|
||||
_loc36_ = _loc9_.m_mass * _loc9_.m_invMass + _loc10_.m_mass * _loc10_.m_invMass;
|
||||
_loc36_ = _loc36_ + (_loc9_.m_mass * _loc9_.m_invI * (_loc8_ - _loc38_ * _loc38_) + _loc10_.m_mass * _loc10_.m_invI * (_loc30_ - _loc41_ * _loc41_));
|
||||
_loc12_.equalizedMass = 1 / _loc36_;
|
||||
_loc26_ = _loc7_;
|
||||
_loc22_ = -_loc5_;
|
||||
_loc34_ = _loc43_ * _loc26_ + _loc45_ * _loc22_;
|
||||
_loc35_ = _loc17_ * _loc26_ + _loc15_ * _loc22_;
|
||||
_loc42_ = _loc9_.m_invMass + _loc10_.m_invMass;
|
||||
_loc42_ = _loc42_ + (_loc9_.m_invI * (_loc8_ - _loc34_ * _loc34_) + _loc10_.m_invI * (_loc30_ - _loc35_ * _loc35_));
|
||||
_loc12_.tangentMass = 1 / _loc42_;
|
||||
_loc12_.velocityBias = 0;
|
||||
if(_loc12_.separation > 0)
|
||||
{
|
||||
_loc12_.velocityBias = -60 * _loc12_.separation;
|
||||
}
|
||||
_loc24_ = _loc21_ + -_loc19_ * _loc15_ - _loc46_ - -_loc18_ * _loc45_;
|
||||
_loc25_ = _loc20_ + _loc19_ * _loc17_ - _loc47_ - _loc18_ * _loc43_;
|
||||
_loc39_ = _loc23_.normal.x * _loc24_ + _loc23_.normal.y * _loc25_;
|
||||
if(_loc39_ < -1)
|
||||
{
|
||||
_loc12_.velocityBias += -_loc23_.restitution * _loc39_;
|
||||
}
|
||||
_loc31_++;
|
||||
}
|
||||
_loc27_++;
|
||||
_loc29_++;
|
||||
}
|
||||
_loc28_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function InitVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc21_:* = null;
|
||||
var _loc22_:* = null;
|
||||
var _loc23_:* = null;
|
||||
var _loc13_:int = 0;
|
||||
var _loc8_:b2ContactConstraint = null;
|
||||
var _loc18_:b2Body = null;
|
||||
var _loc19_:b2Body = null;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc15_:int = 0;
|
||||
var _loc17_:int = 0;
|
||||
var _loc20_:b2ContactConstraintPoint = null;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc16_:b2ContactConstraintPoint = null;
|
||||
_loc13_ = 0;
|
||||
while(_loc13_ < m_constraintCount)
|
||||
{
|
||||
_loc8_ = m_constraints[_loc13_];
|
||||
_loc18_ = _loc8_.body1;
|
||||
_loc19_ = _loc8_.body2;
|
||||
_loc9_ = _loc18_.m_invMass;
|
||||
_loc5_ = _loc18_.m_invI;
|
||||
_loc6_ = _loc19_.m_invMass;
|
||||
_loc3_ = _loc19_.m_invI;
|
||||
_loc4_ = _loc8_.normal.x;
|
||||
_loc11_ = _loc7_ = _loc8_.normal.y;
|
||||
_loc2_ = -_loc4_;
|
||||
if(param1.warmStarting)
|
||||
{
|
||||
_loc17_ = _loc8_.pointCount;
|
||||
_loc15_ = 0;
|
||||
while(_loc15_ < _loc17_)
|
||||
{
|
||||
_loc20_ = _loc8_.points[_loc15_];
|
||||
_loc20_.normalImpulse = _loc20_.normalImpulse * param1.dtRatio;
|
||||
_loc20_.tangentImpulse *= param1.dtRatio;
|
||||
_loc12_ = _loc20_.normalImpulse * _loc4_ + _loc20_.tangentImpulse * _loc11_;
|
||||
_loc14_ = _loc20_.normalImpulse * _loc7_ + _loc20_.tangentImpulse * _loc2_;
|
||||
_loc18_.m_angularVelocity -= _loc5_ * (_loc20_.r1.x * _loc14_ - _loc20_.r1.y * _loc12_);
|
||||
_loc18_.m_linearVelocity.x -= _loc9_ * _loc12_;
|
||||
_loc18_.m_linearVelocity.y -= _loc9_ * _loc14_;
|
||||
_loc19_.m_angularVelocity += _loc3_ * (_loc20_.r2.x * _loc14_ - _loc20_.r2.y * _loc12_);
|
||||
_loc19_.m_linearVelocity.x += _loc6_ * _loc12_;
|
||||
_loc19_.m_linearVelocity.y += _loc6_ * _loc14_;
|
||||
_loc15_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc17_ = _loc8_.pointCount;
|
||||
_loc15_ = 0;
|
||||
while(_loc15_ < _loc17_)
|
||||
{
|
||||
_loc16_ = _loc8_.points[_loc15_];
|
||||
_loc16_.normalImpulse = 0;
|
||||
_loc16_.tangentImpulse = 0;
|
||||
_loc15_++;
|
||||
}
|
||||
}
|
||||
_loc13_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function SolveVelocityConstraints() : void
|
||||
{
|
||||
var _loc24_:int = 0;
|
||||
var _loc14_:b2ContactConstraintPoint = null;
|
||||
var _loc30_:Number = NaN;
|
||||
var _loc34_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc31_:Number = NaN;
|
||||
var _loc38_:Number = NaN;
|
||||
var _loc32_:Number = NaN;
|
||||
var _loc27_:Number = NaN;
|
||||
var _loc35_:Number = NaN;
|
||||
var _loc28_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc33_:* = null;
|
||||
var _loc29_:* = null;
|
||||
var _loc23_:int = 0;
|
||||
var _loc20_:b2ContactConstraint = null;
|
||||
var _loc12_:b2Body = null;
|
||||
var _loc13_:b2Body = null;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc36_:b2Vec2 = null;
|
||||
var _loc37_:b2Vec2 = null;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc1_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc26_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc25_:int = 0;
|
||||
var _loc10_:Number = NaN;
|
||||
_loc23_ = 0;
|
||||
while(_loc23_ < m_constraintCount)
|
||||
{
|
||||
_loc20_ = m_constraints[_loc23_];
|
||||
_loc12_ = _loc20_.body1;
|
||||
_loc13_ = _loc20_.body2;
|
||||
_loc17_ = _loc12_.m_angularVelocity;
|
||||
_loc18_ = _loc13_.m_angularVelocity;
|
||||
_loc36_ = _loc12_.m_linearVelocity;
|
||||
_loc37_ = _loc13_.m_linearVelocity;
|
||||
_loc6_ = _loc12_.m_invMass;
|
||||
_loc3_ = _loc12_.m_invI;
|
||||
_loc4_ = _loc13_.m_invMass;
|
||||
_loc1_ = _loc13_.m_invI;
|
||||
_loc2_ = _loc20_.normal.x;
|
||||
_loc22_ = _loc5_ = _loc20_.normal.y;
|
||||
_loc19_ = -_loc2_;
|
||||
_loc26_ = _loc20_.friction;
|
||||
_loc25_ = _loc20_.pointCount;
|
||||
_loc24_ = 0;
|
||||
while(_loc24_ < _loc25_)
|
||||
{
|
||||
_loc14_ = _loc20_.points[_loc24_];
|
||||
_loc8_ = _loc37_.x + -_loc18_ * _loc14_.r2.y - _loc36_.x - -_loc17_ * _loc14_.r1.y;
|
||||
_loc7_ = _loc37_.y + _loc18_ * _loc14_.r2.x - _loc36_.y - _loc17_ * _loc14_.r1.x;
|
||||
_loc31_ = _loc8_ * _loc2_ + _loc7_ * _loc5_;
|
||||
_loc32_ = -_loc14_.normalMass * (_loc31_ - _loc14_.velocityBias);
|
||||
_loc38_ = _loc8_ * _loc22_ + _loc7_ * _loc19_;
|
||||
_loc27_ = _loc14_.tangentMass * -_loc38_;
|
||||
_loc35_ = b2Math.b2Max(_loc14_.normalImpulse + _loc32_,0);
|
||||
_loc32_ = _loc35_ - _loc14_.normalImpulse;
|
||||
_loc10_ = _loc26_ * _loc14_.normalImpulse;
|
||||
_loc28_ = b2Math.b2Clamp(_loc14_.tangentImpulse + _loc27_,-_loc10_,_loc10_);
|
||||
_loc27_ = _loc28_ - _loc14_.tangentImpulse;
|
||||
_loc9_ = _loc32_ * _loc2_ + _loc27_ * _loc22_;
|
||||
_loc11_ = _loc32_ * _loc5_ + _loc27_ * _loc19_;
|
||||
_loc36_.x -= _loc6_ * _loc9_;
|
||||
_loc36_.y -= _loc6_ * _loc11_;
|
||||
_loc17_ -= _loc3_ * (_loc14_.r1.x * _loc11_ - _loc14_.r1.y * _loc9_);
|
||||
_loc37_.x += _loc4_ * _loc9_;
|
||||
_loc37_.y += _loc4_ * _loc11_;
|
||||
_loc18_ += _loc1_ * (_loc14_.r2.x * _loc11_ - _loc14_.r2.y * _loc9_);
|
||||
_loc14_.normalImpulse = _loc35_;
|
||||
_loc14_.tangentImpulse = _loc28_;
|
||||
_loc24_++;
|
||||
}
|
||||
_loc12_.m_angularVelocity = _loc17_;
|
||||
_loc13_.m_angularVelocity = _loc18_;
|
||||
_loc23_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function FinalizeVelocityConstraints() : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc1_:b2ContactConstraint = null;
|
||||
var _loc4_:b2Manifold = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc5_:b2ManifoldPoint = null;
|
||||
var _loc6_:b2ContactConstraintPoint = null;
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < m_constraintCount)
|
||||
{
|
||||
_loc1_ = m_constraints[_loc2_];
|
||||
_loc4_ = _loc1_.manifold;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc1_.pointCount)
|
||||
{
|
||||
_loc5_ = _loc4_.points[_loc3_];
|
||||
_loc6_ = _loc1_.points[_loc3_];
|
||||
_loc5_.normalImpulse = _loc6_.normalImpulse;
|
||||
_loc5_.tangentImpulse = _loc6_.tangentImpulse;
|
||||
_loc3_++;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function SolvePositionConstraints(param1:Number) : Boolean
|
||||
{
|
||||
var _loc35_:b2Mat22 = null;
|
||||
var _loc32_:b2Vec2 = null;
|
||||
var _loc29_:int = 0;
|
||||
var _loc24_:b2ContactConstraint = null;
|
||||
var _loc12_:b2Body = null;
|
||||
var _loc13_:b2Body = null;
|
||||
var _loc23_:b2Vec2 = null;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc26_:b2Vec2 = null;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc31_:int = 0;
|
||||
var _loc30_:int = 0;
|
||||
var _loc14_:b2ContactConstraintPoint = null;
|
||||
var _loc34_:Number = NaN;
|
||||
var _loc37_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc25_:Number = NaN;
|
||||
var _loc33_:Number = NaN;
|
||||
var _loc36_:Number = NaN;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc38_:Number = NaN;
|
||||
var _loc27_:Number = NaN;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc28_:Number = 0;
|
||||
_loc29_ = 0;
|
||||
while(_loc29_ < m_constraintCount)
|
||||
{
|
||||
_loc24_ = m_constraints[_loc29_];
|
||||
_loc12_ = _loc24_.body1;
|
||||
_loc13_ = _loc24_.body2;
|
||||
_loc23_ = _loc12_.m_sweep.c;
|
||||
_loc21_ = _loc12_.m_sweep.a;
|
||||
_loc26_ = _loc13_.m_sweep.c;
|
||||
_loc19_ = _loc13_.m_sweep.a;
|
||||
_loc7_ = _loc12_.m_mass * _loc12_.m_invMass;
|
||||
_loc4_ = _loc12_.m_mass * _loc12_.m_invI;
|
||||
_loc5_ = _loc13_.m_mass * _loc13_.m_invMass;
|
||||
_loc2_ = _loc13_.m_mass * _loc13_.m_invI;
|
||||
_loc3_ = _loc24_.normal.x;
|
||||
_loc6_ = _loc24_.normal.y;
|
||||
_loc31_ = _loc24_.pointCount;
|
||||
_loc30_ = 0;
|
||||
while(_loc30_ < _loc31_)
|
||||
{
|
||||
_loc14_ = _loc24_.points[_loc30_];
|
||||
_loc35_ = _loc12_.m_xf.R;
|
||||
_loc32_ = _loc12_.m_sweep.localCenter;
|
||||
_loc34_ = _loc14_.localAnchor1.x - _loc32_.x;
|
||||
_loc37_ = _loc14_.localAnchor1.y - _loc32_.y;
|
||||
_loc25_ = _loc35_.col1.x * _loc34_ + _loc35_.col2.x * _loc37_;
|
||||
_loc37_ = _loc35_.col1.y * _loc34_ + _loc35_.col2.y * _loc37_;
|
||||
_loc34_ = _loc25_;
|
||||
_loc35_ = _loc13_.m_xf.R;
|
||||
_loc32_ = _loc13_.m_sweep.localCenter;
|
||||
_loc20_ = _loc14_.localAnchor2.x - _loc32_.x;
|
||||
_loc18_ = _loc14_.localAnchor2.y - _loc32_.y;
|
||||
_loc25_ = _loc35_.col1.x * _loc20_ + _loc35_.col2.x * _loc18_;
|
||||
_loc18_ = _loc35_.col1.y * _loc20_ + _loc35_.col2.y * _loc18_;
|
||||
_loc20_ = _loc25_;
|
||||
_loc33_ = _loc23_.x + _loc34_;
|
||||
_loc36_ = _loc23_.y + _loc37_;
|
||||
_loc17_ = _loc26_.x + _loc20_;
|
||||
_loc16_ = _loc26_.y + _loc18_;
|
||||
_loc11_ = _loc17_ - _loc33_;
|
||||
_loc9_ = _loc16_ - _loc36_;
|
||||
_loc15_ = _loc11_ * _loc3_ + _loc9_ * _loc6_ + _loc14_.separation;
|
||||
_loc28_ = b2Math.b2Min(_loc28_,_loc15_);
|
||||
_loc8_ = param1 * b2Math.b2Clamp(_loc15_ + 0.005,-0.2,0);
|
||||
_loc10_ = -_loc14_.equalizedMass * _loc8_;
|
||||
_loc38_ = _loc14_.positionImpulse;
|
||||
_loc14_.positionImpulse = b2Math.b2Max(_loc38_ + _loc10_,0);
|
||||
_loc10_ = _loc14_.positionImpulse - _loc38_;
|
||||
_loc27_ = _loc10_ * _loc3_;
|
||||
_loc22_ = _loc10_ * _loc6_;
|
||||
_loc23_.x -= _loc7_ * _loc27_;
|
||||
_loc23_.y -= _loc7_ * _loc22_;
|
||||
_loc21_ -= _loc4_ * (_loc34_ * _loc22_ - _loc37_ * _loc27_);
|
||||
_loc12_.m_sweep.a = _loc21_;
|
||||
_loc12_.SynchronizeTransform();
|
||||
_loc26_.x += _loc5_ * _loc27_;
|
||||
_loc26_.y += _loc5_ * _loc22_;
|
||||
_loc19_ += _loc2_ * (_loc20_ * _loc22_ - _loc18_ * _loc27_);
|
||||
_loc13_.m_sweep.a = _loc19_;
|
||||
_loc13_.SynchronizeTransform();
|
||||
_loc30_++;
|
||||
}
|
||||
_loc29_++;
|
||||
}
|
||||
return _loc28_ >= -1.5 * 0.005;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Dynamics.b2ContactListener;
|
||||
|
||||
public class b2NullContact extends b2Contact
|
||||
{
|
||||
|
||||
public function b2NullContact()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function Evaluate(param1:b2ContactListener) : void
|
||||
{
|
||||
}
|
||||
|
||||
override public function GetManifolds() : Array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Collision.Shapes.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.*;
|
||||
|
||||
public class b2PolyAndCircleContact extends b2Contact
|
||||
{
|
||||
|
||||
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
|
||||
|
||||
private var m_manifolds:Array = [new b2Manifold()];
|
||||
|
||||
public var m_manifold:b2Manifold;
|
||||
|
||||
private var m0:b2Manifold = new b2Manifold();
|
||||
|
||||
public function b2PolyAndCircleContact(param1:b2Shape, param2:b2Shape)
|
||||
{
|
||||
super(param1,param2);
|
||||
m_manifold = m_manifolds[0];
|
||||
b2Settings.b2Assert(m_shape1.m_type == 1);
|
||||
b2Settings.b2Assert(m_shape2.m_type == 0);
|
||||
m_manifold.pointCount = 0;
|
||||
var _loc3_:b2ManifoldPoint = m_manifold.points[0];
|
||||
_loc3_.normalImpulse = 0;
|
||||
_loc3_.tangentImpulse = 0;
|
||||
}
|
||||
|
||||
public static function Create(param1:b2Shape, param2:b2Shape, param3:*) : b2Contact
|
||||
{
|
||||
return new b2PolyAndCircleContact(param1,param2);
|
||||
}
|
||||
|
||||
public static function Destroy(param1:b2Contact, param2:*) : void
|
||||
{
|
||||
}
|
||||
|
||||
override public function Evaluate(param1:b2ContactListener) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc11_:b2Vec2 = null;
|
||||
var _loc13_:b2Vec2 = null;
|
||||
var _loc5_:b2ManifoldPoint = null;
|
||||
var _loc2_:b2ManifoldPoint = null;
|
||||
var _loc10_:Boolean = false;
|
||||
var _loc9_:* = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc7_:b2Body = m_shape1.m_body;
|
||||
var _loc8_:b2Body = m_shape2.m_body;
|
||||
m0.Set(m_manifold);
|
||||
b2Collision.b2CollidePolygonAndCircle(m_manifold,m_shape1 as b2PolygonShape,_loc7_.m_xf,m_shape2 as b2CircleShape,_loc8_.m_xf);
|
||||
var _loc12_:Array = [false,false];
|
||||
var _loc6_:b2ContactPoint = s_evalCP;
|
||||
_loc6_.shape1 = m_shape1;
|
||||
_loc6_.shape2 = m_shape2;
|
||||
_loc6_.friction = m_friction;
|
||||
_loc6_.restitution = m_restitution;
|
||||
if(m_manifold.pointCount > 0)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < m_manifold.pointCount)
|
||||
{
|
||||
_loc2_ = m_manifold.points[_loc3_];
|
||||
_loc2_.normalImpulse = 0;
|
||||
_loc2_.tangentImpulse = 0;
|
||||
_loc10_ = false;
|
||||
_loc9_ = _loc2_.id._key;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < m0.pointCount)
|
||||
{
|
||||
if(_loc12_[_loc4_] != true)
|
||||
{
|
||||
_loc5_ = m0.points[_loc4_];
|
||||
if(_loc5_.id._key == _loc9_)
|
||||
{
|
||||
_loc12_[_loc4_] = true;
|
||||
_loc2_.normalImpulse = _loc5_.normalImpulse;
|
||||
_loc2_.tangentImpulse = _loc5_.tangentImpulse;
|
||||
_loc10_ = true;
|
||||
if(param1 != null)
|
||||
{
|
||||
_loc6_.position = _loc7_.GetWorldPoint(_loc2_.localPoint1);
|
||||
_loc11_ = _loc7_.GetLinearVelocityFromLocalPoint(_loc2_.localPoint1);
|
||||
_loc13_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc2_.localPoint2);
|
||||
_loc6_.velocity.Set(_loc13_.x - _loc11_.x,_loc13_.y - _loc11_.y);
|
||||
_loc6_.normal.SetV(m_manifold.normal);
|
||||
_loc6_.separation = _loc2_.separation;
|
||||
_loc6_.id.key = _loc9_;
|
||||
param1.Persist(_loc6_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
if(_loc10_ == false && param1 != null)
|
||||
{
|
||||
_loc6_.position = _loc7_.GetWorldPoint(_loc2_.localPoint1);
|
||||
_loc11_ = _loc7_.GetLinearVelocityFromLocalPoint(_loc2_.localPoint1);
|
||||
_loc13_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc2_.localPoint2);
|
||||
_loc6_.velocity.Set(_loc13_.x - _loc11_.x,_loc13_.y - _loc11_.y);
|
||||
_loc6_.normal.SetV(m_manifold.normal);
|
||||
_loc6_.separation = _loc2_.separation;
|
||||
_loc6_.id.key = _loc9_;
|
||||
param1.Add(_loc6_);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
m_manifoldCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_manifoldCount = 0;
|
||||
}
|
||||
if(param1 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < m0.pointCount)
|
||||
{
|
||||
if(!_loc12_[_loc3_])
|
||||
{
|
||||
_loc5_ = m0.points[_loc3_];
|
||||
_loc6_.position = _loc7_.GetWorldPoint(_loc5_.localPoint1);
|
||||
_loc11_ = _loc7_.GetLinearVelocityFromLocalPoint(_loc5_.localPoint1);
|
||||
_loc13_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc5_.localPoint2);
|
||||
_loc6_.velocity.Set(_loc13_.x - _loc11_.x,_loc13_.y - _loc11_.y);
|
||||
_loc6_.normal.SetV(m0.normal);
|
||||
_loc6_.separation = _loc5_.separation;
|
||||
_loc6_.id.key = _loc5_.id._key;
|
||||
param1.Remove(_loc6_);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
override public function GetManifolds() : Array
|
||||
{
|
||||
return m_manifolds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
package Box2D.Dynamics.Contacts
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Collision.Shapes.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.*;
|
||||
|
||||
public class b2PolygonContact extends b2Contact
|
||||
{
|
||||
|
||||
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
|
||||
|
||||
private var m0:b2Manifold = new b2Manifold();
|
||||
|
||||
private var m_manifolds:Array = [new b2Manifold()];
|
||||
|
||||
public var m_manifold:b2Manifold;
|
||||
|
||||
public function b2PolygonContact(param1:b2Shape, param2:b2Shape)
|
||||
{
|
||||
super(param1,param2);
|
||||
m_manifold = m_manifolds[0];
|
||||
m_manifold.pointCount = 0;
|
||||
}
|
||||
|
||||
public static function Create(param1:b2Shape, param2:b2Shape, param3:*) : b2Contact
|
||||
{
|
||||
return new b2PolygonContact(param1,param2);
|
||||
}
|
||||
|
||||
public static function Destroy(param1:b2Contact, param2:*) : void
|
||||
{
|
||||
}
|
||||
|
||||
override public function Evaluate(param1:b2ContactListener) : void
|
||||
{
|
||||
var _loc11_:b2Vec2 = null;
|
||||
var _loc13_:b2Vec2 = null;
|
||||
var _loc5_:b2ManifoldPoint = null;
|
||||
var _loc6_:b2ContactPoint = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:b2ManifoldPoint = null;
|
||||
var _loc10_:Boolean = false;
|
||||
var _loc9_:* = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc7_:b2Body = m_shape1.m_body;
|
||||
var _loc8_:b2Body = m_shape2.m_body;
|
||||
m0.Set(m_manifold);
|
||||
b2Collision.b2CollidePolygons(m_manifold,m_shape1 as b2PolygonShape,_loc7_.m_xf,m_shape2 as b2PolygonShape,_loc8_.m_xf);
|
||||
var _loc12_:Array = [false,false];
|
||||
_loc6_ = s_evalCP;
|
||||
_loc6_.shape1 = m_shape1;
|
||||
_loc6_.shape2 = m_shape2;
|
||||
_loc6_.friction = m_friction;
|
||||
_loc6_.restitution = m_restitution;
|
||||
if(m_manifold.pointCount > 0)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < m_manifold.pointCount)
|
||||
{
|
||||
_loc2_ = m_manifold.points[_loc3_];
|
||||
_loc2_.normalImpulse = 0;
|
||||
_loc2_.tangentImpulse = 0;
|
||||
_loc10_ = false;
|
||||
_loc9_ = _loc2_.id._key;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < m0.pointCount)
|
||||
{
|
||||
if(_loc12_[_loc4_] != true)
|
||||
{
|
||||
_loc5_ = m0.points[_loc4_];
|
||||
if(_loc5_.id._key == _loc9_)
|
||||
{
|
||||
_loc12_[_loc4_] = true;
|
||||
_loc2_.normalImpulse = _loc5_.normalImpulse;
|
||||
_loc2_.tangentImpulse = _loc5_.tangentImpulse;
|
||||
_loc10_ = true;
|
||||
if(param1 != null)
|
||||
{
|
||||
_loc6_.position = _loc7_.GetWorldPoint(_loc2_.localPoint1);
|
||||
_loc11_ = _loc7_.GetLinearVelocityFromLocalPoint(_loc2_.localPoint1);
|
||||
_loc13_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc2_.localPoint2);
|
||||
_loc6_.velocity.Set(_loc13_.x - _loc11_.x,_loc13_.y - _loc11_.y);
|
||||
_loc6_.normal.SetV(m_manifold.normal);
|
||||
_loc6_.separation = _loc2_.separation;
|
||||
_loc6_.id.key = _loc9_;
|
||||
param1.Persist(_loc6_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
if(_loc10_ == false && param1 != null)
|
||||
{
|
||||
_loc6_.position = _loc7_.GetWorldPoint(_loc2_.localPoint1);
|
||||
_loc11_ = _loc7_.GetLinearVelocityFromLocalPoint(_loc2_.localPoint1);
|
||||
_loc13_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc2_.localPoint2);
|
||||
_loc6_.velocity.Set(_loc13_.x - _loc11_.x,_loc13_.y - _loc11_.y);
|
||||
_loc6_.normal.SetV(m_manifold.normal);
|
||||
_loc6_.separation = _loc2_.separation;
|
||||
_loc6_.id.key = _loc9_;
|
||||
param1.Add(_loc6_);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
m_manifoldCount = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_manifoldCount = 0;
|
||||
}
|
||||
if(param1 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < m0.pointCount)
|
||||
{
|
||||
if(!_loc12_[_loc3_])
|
||||
{
|
||||
_loc5_ = m0.points[_loc3_];
|
||||
_loc6_.position = _loc7_.GetWorldPoint(_loc5_.localPoint1);
|
||||
_loc11_ = _loc7_.GetLinearVelocityFromLocalPoint(_loc5_.localPoint1);
|
||||
_loc13_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc5_.localPoint2);
|
||||
_loc6_.velocity.Set(_loc13_.x - _loc11_.x,_loc13_.y - _loc11_.y);
|
||||
_loc6_.normal.SetV(m0.normal);
|
||||
_loc6_.separation = _loc5_.separation;
|
||||
_loc6_.id.key = _loc5_.id._key;
|
||||
param1.Remove(_loc6_);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
override public function GetManifolds() : Array
|
||||
{
|
||||
return m_manifolds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,218 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Mat22;
|
||||
import Box2D.Common.Math.b2Math;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import Box2D.Dynamics.b2TimeStep;
|
||||
|
||||
public class b2DistanceJoint extends b2Joint
|
||||
{
|
||||
|
||||
public var m_localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_u:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_frequencyHz:Number;
|
||||
|
||||
public var m_dampingRatio:Number;
|
||||
|
||||
public var m_gamma:Number;
|
||||
|
||||
public var m_bias:Number;
|
||||
|
||||
public var m_impulse:Number;
|
||||
|
||||
public var m_mass:Number;
|
||||
|
||||
public var m_length:Number;
|
||||
|
||||
public function b2DistanceJoint(param1:b2DistanceJointDef)
|
||||
{
|
||||
var _loc4_:* = null;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
super(param1);
|
||||
m_localAnchor1.SetV(param1.localAnchor1);
|
||||
m_localAnchor2.SetV(param1.localAnchor2);
|
||||
m_length = param1.length;
|
||||
m_frequencyHz = param1.frequencyHz;
|
||||
m_dampingRatio = param1.dampingRatio;
|
||||
m_impulse = 0;
|
||||
m_gamma = 0;
|
||||
m_bias = 0;
|
||||
m_inv_dt = 0;
|
||||
}
|
||||
|
||||
override public function InitVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc15_:b2Mat22 = null;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
m_inv_dt = param1.inv_dt;
|
||||
var _loc11_:b2Body = m_body1;
|
||||
var _loc12_:b2Body = m_body2;
|
||||
_loc15_ = _loc11_.m_xf.R;
|
||||
var _loc13_:Number = m_localAnchor1.x - _loc11_.m_sweep.localCenter.x;
|
||||
var _loc17_:Number = m_localAnchor1.y - _loc11_.m_sweep.localCenter.y;
|
||||
_loc4_ = _loc15_.col1.x * _loc13_ + _loc15_.col2.x * _loc17_;
|
||||
_loc17_ = _loc15_.col1.y * _loc13_ + _loc15_.col2.y * _loc17_;
|
||||
_loc13_ = _loc4_;
|
||||
_loc15_ = _loc12_.m_xf.R;
|
||||
var _loc16_:Number = m_localAnchor2.x - _loc12_.m_sweep.localCenter.x;
|
||||
var _loc14_:Number = m_localAnchor2.y - _loc12_.m_sweep.localCenter.y;
|
||||
_loc4_ = _loc15_.col1.x * _loc16_ + _loc15_.col2.x * _loc14_;
|
||||
_loc14_ = _loc15_.col1.y * _loc16_ + _loc15_.col2.y * _loc14_;
|
||||
_loc16_ = _loc4_;
|
||||
m_u.x = _loc12_.m_sweep.c.x + _loc16_ - _loc11_.m_sweep.c.x - _loc13_;
|
||||
m_u.y = _loc12_.m_sweep.c.y + _loc14_ - _loc11_.m_sweep.c.y - _loc17_;
|
||||
var _loc6_:Number = Math.sqrt(m_u.x * m_u.x + m_u.y * m_u.y);
|
||||
if(_loc6_ > 0.005)
|
||||
{
|
||||
m_u.Multiply(1 / _loc6_);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_u.SetZero();
|
||||
}
|
||||
var _loc19_:Number = _loc13_ * m_u.y - _loc17_ * m_u.x;
|
||||
var _loc18_:Number = _loc16_ * m_u.y - _loc14_ * m_u.x;
|
||||
var _loc2_:Number = _loc11_.m_invMass + _loc11_.m_invI * _loc19_ * _loc19_ + _loc12_.m_invMass + _loc12_.m_invI * _loc18_ * _loc18_;
|
||||
m_mass = 1 / _loc2_;
|
||||
if(m_frequencyHz > 0)
|
||||
{
|
||||
_loc3_ = _loc6_ - m_length;
|
||||
_loc10_ = 2 * 3.141592653589793 * m_frequencyHz;
|
||||
_loc5_ = 2 * m_mass * m_dampingRatio * _loc10_;
|
||||
_loc9_ = m_mass * _loc10_ * _loc10_;
|
||||
m_gamma = 1 / (param1.dt * (_loc5_ + param1.dt * _loc9_));
|
||||
m_bias = _loc3_ * param1.dt * _loc9_ * m_gamma;
|
||||
m_mass = 1 / (_loc2_ + m_gamma);
|
||||
}
|
||||
if(param1.warmStarting)
|
||||
{
|
||||
m_impulse *= param1.dtRatio;
|
||||
_loc7_ = m_impulse * m_u.x;
|
||||
_loc8_ = m_impulse * m_u.y;
|
||||
_loc11_.m_linearVelocity.x -= _loc11_.m_invMass * _loc7_;
|
||||
_loc11_.m_linearVelocity.y -= _loc11_.m_invMass * _loc8_;
|
||||
_loc11_.m_angularVelocity -= _loc11_.m_invI * (_loc13_ * _loc8_ - _loc17_ * _loc7_);
|
||||
_loc12_.m_linearVelocity.x += _loc12_.m_invMass * _loc7_;
|
||||
_loc12_.m_linearVelocity.y += _loc12_.m_invMass * _loc8_;
|
||||
_loc12_.m_angularVelocity += _loc12_.m_invI * (_loc16_ * _loc8_ - _loc14_ * _loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_impulse = 0;
|
||||
}
|
||||
}
|
||||
|
||||
override public function SolveVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc9_:b2Mat22 = null;
|
||||
var _loc5_:b2Body = m_body1;
|
||||
var _loc6_:b2Body = m_body2;
|
||||
_loc9_ = _loc5_.m_xf.R;
|
||||
var _loc7_:Number = m_localAnchor1.x - _loc5_.m_sweep.localCenter.x;
|
||||
var _loc13_:Number = m_localAnchor1.y - _loc5_.m_sweep.localCenter.y;
|
||||
var _loc2_:Number = _loc9_.col1.x * _loc7_ + _loc9_.col2.x * _loc13_;
|
||||
_loc13_ = _loc9_.col1.y * _loc7_ + _loc9_.col2.y * _loc13_;
|
||||
_loc7_ = _loc2_;
|
||||
_loc9_ = _loc6_.m_xf.R;
|
||||
var _loc10_:Number = m_localAnchor2.x - _loc6_.m_sweep.localCenter.x;
|
||||
var _loc8_:Number = m_localAnchor2.y - _loc6_.m_sweep.localCenter.y;
|
||||
_loc2_ = _loc9_.col1.x * _loc10_ + _loc9_.col2.x * _loc8_;
|
||||
_loc8_ = _loc9_.col1.y * _loc10_ + _loc9_.col2.y * _loc8_;
|
||||
_loc10_ = _loc2_;
|
||||
var _loc14_:Number = _loc5_.m_linearVelocity.x + -_loc5_.m_angularVelocity * _loc13_;
|
||||
var _loc17_:Number = _loc5_.m_linearVelocity.y + _loc5_.m_angularVelocity * _loc7_;
|
||||
var _loc16_:Number = _loc6_.m_linearVelocity.x + -_loc6_.m_angularVelocity * _loc8_;
|
||||
var _loc15_:Number = _loc6_.m_linearVelocity.y + _loc6_.m_angularVelocity * _loc10_;
|
||||
var _loc11_:Number = m_u.x * (_loc16_ - _loc14_) + m_u.y * (_loc15_ - _loc17_);
|
||||
var _loc12_:Number = -m_mass * (_loc11_ + m_bias + m_gamma * m_impulse);
|
||||
m_impulse += _loc12_;
|
||||
var _loc3_:Number = _loc12_ * m_u.x;
|
||||
var _loc4_:Number = _loc12_ * m_u.y;
|
||||
_loc5_.m_linearVelocity.x -= _loc5_.m_invMass * _loc3_;
|
||||
_loc5_.m_linearVelocity.y -= _loc5_.m_invMass * _loc4_;
|
||||
_loc5_.m_angularVelocity -= _loc5_.m_invI * (_loc7_ * _loc4_ - _loc13_ * _loc3_);
|
||||
_loc6_.m_linearVelocity.x += _loc6_.m_invMass * _loc3_;
|
||||
_loc6_.m_linearVelocity.y += _loc6_.m_invMass * _loc4_;
|
||||
_loc6_.m_angularVelocity += _loc6_.m_invI * (_loc10_ * _loc4_ - _loc8_ * _loc3_);
|
||||
}
|
||||
|
||||
override public function SolvePositionConstraints() : Boolean
|
||||
{
|
||||
var _loc12_:b2Mat22 = null;
|
||||
if(m_frequencyHz > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
var _loc6_:b2Body = m_body1;
|
||||
var _loc7_:b2Body = m_body2;
|
||||
_loc12_ = _loc6_.m_xf.R;
|
||||
var _loc10_:Number = m_localAnchor1.x - _loc6_.m_sweep.localCenter.x;
|
||||
var _loc15_:Number = m_localAnchor1.y - _loc6_.m_sweep.localCenter.y;
|
||||
var _loc2_:Number = _loc12_.col1.x * _loc10_ + _loc12_.col2.x * _loc15_;
|
||||
_loc15_ = _loc12_.col1.y * _loc10_ + _loc12_.col2.y * _loc15_;
|
||||
_loc10_ = _loc2_;
|
||||
_loc12_ = _loc7_.m_xf.R;
|
||||
var _loc13_:Number = m_localAnchor2.x - _loc7_.m_sweep.localCenter.x;
|
||||
var _loc11_:Number = m_localAnchor2.y - _loc7_.m_sweep.localCenter.y;
|
||||
_loc2_ = _loc12_.col1.x * _loc13_ + _loc12_.col2.x * _loc11_;
|
||||
_loc11_ = _loc12_.col1.y * _loc13_ + _loc12_.col2.y * _loc11_;
|
||||
_loc13_ = _loc2_;
|
||||
var _loc8_:Number = _loc7_.m_sweep.c.x + _loc13_ - _loc6_.m_sweep.c.x - _loc10_;
|
||||
var _loc9_:Number = _loc7_.m_sweep.c.y + _loc11_ - _loc6_.m_sweep.c.y - _loc15_;
|
||||
var _loc3_:Number = Math.sqrt(_loc8_ * _loc8_ + _loc9_ * _loc9_);
|
||||
_loc8_ /= _loc3_;
|
||||
_loc9_ /= _loc3_;
|
||||
var _loc1_:Number = _loc3_ - m_length;
|
||||
_loc1_ = b2Math.b2Clamp(_loc1_,-0.2,0.2);
|
||||
var _loc14_:Number = -m_mass * _loc1_;
|
||||
m_u.Set(_loc8_,_loc9_);
|
||||
var _loc4_:Number = _loc14_ * m_u.x;
|
||||
var _loc5_:Number = _loc14_ * m_u.y;
|
||||
_loc6_.m_sweep.c.x -= _loc6_.m_invMass * _loc4_;
|
||||
_loc6_.m_sweep.c.y -= _loc6_.m_invMass * _loc5_;
|
||||
_loc6_.m_sweep.a -= _loc6_.m_invI * (_loc10_ * _loc5_ - _loc15_ * _loc4_);
|
||||
_loc7_.m_sweep.c.x += _loc7_.m_invMass * _loc4_;
|
||||
_loc7_.m_sweep.c.y += _loc7_.m_invMass * _loc5_;
|
||||
_loc7_.m_sweep.a += _loc7_.m_invI * (_loc13_ * _loc5_ - _loc11_ * _loc4_);
|
||||
_loc6_.SynchronizeTransform();
|
||||
_loc7_.SynchronizeTransform();
|
||||
return b2Math.b2Abs(_loc1_) < 0.005;
|
||||
}
|
||||
|
||||
override public function GetAnchor1() : b2Vec2
|
||||
{
|
||||
return m_body1.GetWorldPoint(m_localAnchor1);
|
||||
}
|
||||
|
||||
override public function GetAnchor2() : b2Vec2
|
||||
{
|
||||
return m_body2.GetWorldPoint(m_localAnchor2);
|
||||
}
|
||||
|
||||
override public function GetReactionForce() : b2Vec2
|
||||
{
|
||||
var _loc1_:b2Vec2 = new b2Vec2();
|
||||
_loc1_.SetV(m_u);
|
||||
_loc1_.Multiply(m_inv_dt * m_impulse);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function GetReactionTorque() : Number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
|
||||
public class b2DistanceJointDef extends b2JointDef
|
||||
{
|
||||
|
||||
public var localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var length:Number;
|
||||
|
||||
public var frequencyHz:Number;
|
||||
|
||||
public var dampingRatio:Number;
|
||||
|
||||
public function b2DistanceJointDef()
|
||||
{
|
||||
super();
|
||||
type = 3;
|
||||
length = 1;
|
||||
frequencyHz = 0;
|
||||
dampingRatio = 0;
|
||||
}
|
||||
|
||||
public function Initialize(param1:b2Body, param2:b2Body, param3:b2Vec2, param4:b2Vec2) : void
|
||||
{
|
||||
body1 = param1;
|
||||
body2 = param2;
|
||||
localAnchor1.SetV(body1.GetLocalPoint(param3));
|
||||
localAnchor2.SetV(body2.GetLocalPoint(param4));
|
||||
var _loc5_:Number = param4.x - param3.x;
|
||||
var _loc6_:Number = param4.y - param3.y;
|
||||
length = Math.sqrt(_loc5_ * _loc5_ + _loc6_ * _loc6_);
|
||||
frequencyHz = 0;
|
||||
dampingRatio = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Mat22;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import Box2D.Dynamics.b2TimeStep;
|
||||
|
||||
public class b2GearJoint extends b2Joint
|
||||
{
|
||||
|
||||
public var m_ground1:b2Body;
|
||||
|
||||
public var m_ground2:b2Body;
|
||||
|
||||
public var m_revolute1:b2RevoluteJoint;
|
||||
|
||||
public var m_prismatic1:b2PrismaticJoint;
|
||||
|
||||
public var m_revolute2:b2RevoluteJoint;
|
||||
|
||||
public var m_prismatic2:b2PrismaticJoint;
|
||||
|
||||
public var m_groundAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_groundAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_J:b2Jacobian = new b2Jacobian();
|
||||
|
||||
public var m_constant:Number;
|
||||
|
||||
public var m_ratio:Number;
|
||||
|
||||
public var m_mass:Number;
|
||||
|
||||
public var m_force:Number;
|
||||
|
||||
public function b2GearJoint(param1:b2GearJointDef)
|
||||
{
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
super(param1);
|
||||
var _loc5_:int = param1.joint1.m_type;
|
||||
var _loc2_:int = param1.joint2.m_type;
|
||||
m_revolute1 = null;
|
||||
m_prismatic1 = null;
|
||||
m_revolute2 = null;
|
||||
m_prismatic2 = null;
|
||||
m_ground1 = param1.joint1.m_body1;
|
||||
m_body1 = param1.joint1.m_body2;
|
||||
if(_loc5_ == 1)
|
||||
{
|
||||
m_revolute1 = param1.joint1 as b2RevoluteJoint;
|
||||
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
|
||||
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
|
||||
_loc4_ = m_revolute1.GetJointAngle();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_prismatic1 = param1.joint1 as b2PrismaticJoint;
|
||||
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
|
||||
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
|
||||
_loc4_ = m_prismatic1.GetJointTranslation();
|
||||
}
|
||||
m_ground2 = param1.joint2.m_body1;
|
||||
m_body2 = param1.joint2.m_body2;
|
||||
if(_loc2_ == 1)
|
||||
{
|
||||
m_revolute2 = param1.joint2 as b2RevoluteJoint;
|
||||
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
|
||||
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
|
||||
_loc3_ = m_revolute2.GetJointAngle();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_prismatic2 = param1.joint2 as b2PrismaticJoint;
|
||||
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
|
||||
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
|
||||
_loc3_ = m_prismatic2.GetJointTranslation();
|
||||
}
|
||||
m_ratio = param1.ratio;
|
||||
m_constant = _loc4_ + m_ratio * _loc3_;
|
||||
m_force = 0;
|
||||
}
|
||||
|
||||
override public function GetAnchor1() : b2Vec2
|
||||
{
|
||||
return m_body1.GetWorldPoint(m_localAnchor1);
|
||||
}
|
||||
|
||||
override public function GetAnchor2() : b2Vec2
|
||||
{
|
||||
return m_body2.GetWorldPoint(m_localAnchor2);
|
||||
}
|
||||
|
||||
override public function GetReactionForce() : b2Vec2
|
||||
{
|
||||
return new b2Vec2(m_force * m_J.linear2.x,m_force * m_J.linear2.y);
|
||||
}
|
||||
|
||||
override public function GetReactionTorque() : Number
|
||||
{
|
||||
var _loc4_:b2Mat22 = m_body2.m_xf.R;
|
||||
var _loc2_:Number = m_localAnchor1.x - m_body2.m_sweep.localCenter.x;
|
||||
var _loc3_:Number = m_localAnchor1.y - m_body2.m_sweep.localCenter.y;
|
||||
var _loc1_:Number = _loc4_.col1.x * _loc2_ + _loc4_.col2.x * _loc3_;
|
||||
_loc3_ = _loc4_.col1.y * _loc2_ + _loc4_.col2.y * _loc3_;
|
||||
_loc2_ = _loc1_;
|
||||
return m_force * m_J.angular2 - (_loc2_ * (m_force * m_J.linear2.y) - _loc3_ * (m_force * m_J.linear2.x));
|
||||
}
|
||||
|
||||
public function GetRatio() : Number
|
||||
{
|
||||
return m_ratio;
|
||||
}
|
||||
|
||||
override public function InitVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc15_:b2Mat22 = null;
|
||||
var _loc14_:b2Vec2 = null;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc7_:b2Body = m_ground1;
|
||||
var _loc8_:b2Body = m_ground2;
|
||||
var _loc10_:b2Body = m_body1;
|
||||
var _loc12_:b2Body = m_body2;
|
||||
var _loc9_:Number = 0;
|
||||
m_J.SetZero();
|
||||
if(m_revolute1)
|
||||
{
|
||||
m_J.angular1 = -1;
|
||||
_loc9_ += _loc10_.m_invI;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc15_ = _loc7_.m_xf.R;
|
||||
_loc14_ = m_prismatic1.m_localXAxis1;
|
||||
_loc5_ = _loc15_.col1.x * _loc14_.x + _loc15_.col2.x * _loc14_.y;
|
||||
_loc3_ = _loc15_.col1.y * _loc14_.x + _loc15_.col2.y * _loc14_.y;
|
||||
_loc15_ = _loc10_.m_xf.R;
|
||||
_loc4_ = m_localAnchor1.x - _loc10_.m_sweep.localCenter.x;
|
||||
_loc6_ = m_localAnchor1.y - _loc10_.m_sweep.localCenter.y;
|
||||
_loc2_ = _loc15_.col1.x * _loc4_ + _loc15_.col2.x * _loc6_;
|
||||
_loc6_ = _loc15_.col1.y * _loc4_ + _loc15_.col2.y * _loc6_;
|
||||
_loc4_ = _loc2_;
|
||||
_loc11_ = _loc4_ * _loc3_ - _loc6_ * _loc5_;
|
||||
m_J.linear1.Set(-_loc5_,-_loc3_);
|
||||
m_J.angular1 = -_loc11_;
|
||||
_loc9_ += _loc10_.m_invMass + _loc10_.m_invI * _loc11_ * _loc11_;
|
||||
}
|
||||
if(m_revolute2)
|
||||
{
|
||||
m_J.angular2 = -m_ratio;
|
||||
_loc9_ += m_ratio * m_ratio * _loc12_.m_invI;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc15_ = _loc8_.m_xf.R;
|
||||
_loc14_ = m_prismatic2.m_localXAxis1;
|
||||
_loc5_ = _loc15_.col1.x * _loc14_.x + _loc15_.col2.x * _loc14_.y;
|
||||
_loc3_ = _loc15_.col1.y * _loc14_.x + _loc15_.col2.y * _loc14_.y;
|
||||
_loc15_ = _loc12_.m_xf.R;
|
||||
_loc4_ = m_localAnchor2.x - _loc12_.m_sweep.localCenter.x;
|
||||
_loc6_ = m_localAnchor2.y - _loc12_.m_sweep.localCenter.y;
|
||||
_loc2_ = _loc15_.col1.x * _loc4_ + _loc15_.col2.x * _loc6_;
|
||||
_loc6_ = _loc15_.col1.y * _loc4_ + _loc15_.col2.y * _loc6_;
|
||||
_loc4_ = _loc2_;
|
||||
_loc11_ = _loc4_ * _loc3_ - _loc6_ * _loc5_;
|
||||
m_J.linear2.Set(-m_ratio * _loc5_,-m_ratio * _loc3_);
|
||||
m_J.angular2 = -m_ratio * _loc11_;
|
||||
_loc9_ += m_ratio * m_ratio * (_loc12_.m_invMass + _loc12_.m_invI * _loc11_ * _loc11_);
|
||||
}
|
||||
m_mass = 1 / _loc9_;
|
||||
if(param1.warmStarting)
|
||||
{
|
||||
_loc13_ = param1.dt * m_force;
|
||||
_loc10_.m_linearVelocity.x += _loc10_.m_invMass * _loc13_ * m_J.linear1.x;
|
||||
_loc10_.m_linearVelocity.y += _loc10_.m_invMass * _loc13_ * m_J.linear1.y;
|
||||
_loc10_.m_angularVelocity += _loc10_.m_invI * _loc13_ * m_J.angular1;
|
||||
_loc12_.m_linearVelocity.x += _loc12_.m_invMass * _loc13_ * m_J.linear2.x;
|
||||
_loc12_.m_linearVelocity.y += _loc12_.m_invMass * _loc13_ * m_J.linear2.y;
|
||||
_loc12_.m_angularVelocity += _loc12_.m_invI * _loc13_ * m_J.angular2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_force = 0;
|
||||
}
|
||||
}
|
||||
|
||||
override public function SolveVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc6_:b2Body = m_body1;
|
||||
var _loc2_:b2Body = m_body2;
|
||||
var _loc4_:Number = m_J.Compute(_loc6_.m_linearVelocity,_loc6_.m_angularVelocity,_loc2_.m_linearVelocity,_loc2_.m_angularVelocity);
|
||||
var _loc5_:Number = -param1.inv_dt * m_mass * _loc4_;
|
||||
m_force += _loc5_;
|
||||
var _loc3_:Number = param1.dt * _loc5_;
|
||||
_loc6_.m_linearVelocity.x += _loc6_.m_invMass * _loc3_ * m_J.linear1.x;
|
||||
_loc6_.m_linearVelocity.y += _loc6_.m_invMass * _loc3_ * m_J.linear1.y;
|
||||
_loc6_.m_angularVelocity += _loc6_.m_invI * _loc3_ * m_J.angular1;
|
||||
_loc2_.m_linearVelocity.x += _loc2_.m_invMass * _loc3_ * m_J.linear2.x;
|
||||
_loc2_.m_linearVelocity.y += _loc2_.m_invMass * _loc3_ * m_J.linear2.y;
|
||||
_loc2_.m_angularVelocity += _loc2_.m_invI * _loc3_ * m_J.angular2;
|
||||
}
|
||||
|
||||
override public function SolvePositionConstraints() : Boolean
|
||||
{
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc2_:Number = 0;
|
||||
var _loc7_:b2Body = m_body1;
|
||||
var _loc1_:b2Body = m_body2;
|
||||
if(m_revolute1)
|
||||
{
|
||||
_loc5_ = m_revolute1.GetJointAngle();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = m_prismatic1.GetJointTranslation();
|
||||
}
|
||||
if(m_revolute2)
|
||||
{
|
||||
_loc4_ = m_revolute2.GetJointAngle();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc4_ = m_prismatic2.GetJointTranslation();
|
||||
}
|
||||
var _loc3_:Number = m_constant - (_loc5_ + m_ratio * _loc4_);
|
||||
var _loc6_:Number = -m_mass * _loc3_;
|
||||
_loc7_.m_sweep.c.x += _loc7_.m_invMass * _loc6_ * m_J.linear1.x;
|
||||
_loc7_.m_sweep.c.y += _loc7_.m_invMass * _loc6_ * m_J.linear1.y;
|
||||
_loc7_.m_sweep.a += _loc7_.m_invI * _loc6_ * m_J.angular1;
|
||||
_loc1_.m_sweep.c.x += _loc1_.m_invMass * _loc6_ * m_J.linear2.x;
|
||||
_loc1_.m_sweep.c.y += _loc1_.m_invMass * _loc6_ * m_J.linear2.y;
|
||||
_loc1_.m_sweep.a += _loc1_.m_invI * _loc6_ * m_J.angular2;
|
||||
_loc7_.SynchronizeTransform();
|
||||
_loc1_.SynchronizeTransform();
|
||||
return _loc2_ < 0.005;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
public class b2GearJointDef extends b2JointDef
|
||||
{
|
||||
|
||||
public var joint1:b2Joint;
|
||||
|
||||
public var joint2:b2Joint;
|
||||
|
||||
public var ratio:Number;
|
||||
|
||||
public function b2GearJointDef()
|
||||
{
|
||||
super();
|
||||
type = 6;
|
||||
joint1 = null;
|
||||
joint2 = null;
|
||||
ratio = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2Jacobian
|
||||
{
|
||||
|
||||
public var linear1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var angular1:Number;
|
||||
|
||||
public var linear2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var angular2:Number;
|
||||
|
||||
public function b2Jacobian()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function SetZero() : void
|
||||
{
|
||||
linear1.SetZero();
|
||||
angular1 = 0;
|
||||
linear2.SetZero();
|
||||
angular2 = 0;
|
||||
}
|
||||
|
||||
public function Set(param1:b2Vec2, param2:Number, param3:b2Vec2, param4:Number) : void
|
||||
{
|
||||
linear1.SetV(param1);
|
||||
angular1 = param2;
|
||||
linear2.SetV(param3);
|
||||
angular2 = param4;
|
||||
}
|
||||
|
||||
public function Compute(param1:b2Vec2, param2:Number, param3:b2Vec2, param4:Number) : Number
|
||||
{
|
||||
return linear1.x * param1.x + linear1.y * param1.y + angular1 * param2 + (linear2.x * param3.x + linear2.y * param3.y) + angular2 * param4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import Box2D.Dynamics.b2TimeStep;
|
||||
|
||||
public class b2Joint
|
||||
{
|
||||
|
||||
public static const e_unknownJoint:int = 0;
|
||||
|
||||
public static const e_revoluteJoint:int = 1;
|
||||
|
||||
public static const e_prismaticJoint:int = 2;
|
||||
|
||||
public static const e_distanceJoint:int = 3;
|
||||
|
||||
public static const e_pulleyJoint:int = 4;
|
||||
|
||||
public static const e_mouseJoint:int = 5;
|
||||
|
||||
public static const e_gearJoint:int = 6;
|
||||
|
||||
public static const e_inactiveLimit:int = 0;
|
||||
|
||||
public static const e_atLowerLimit:int = 1;
|
||||
|
||||
public static const e_atUpperLimit:int = 2;
|
||||
|
||||
public static const e_equalLimits:int = 3;
|
||||
|
||||
public var m_type:int;
|
||||
|
||||
public var m_prev:b2Joint;
|
||||
|
||||
public var m_next:b2Joint;
|
||||
|
||||
public var m_node1:b2JointEdge = new b2JointEdge();
|
||||
|
||||
public var m_node2:b2JointEdge = new b2JointEdge();
|
||||
|
||||
public var m_body1:b2Body;
|
||||
|
||||
public var m_body2:b2Body;
|
||||
|
||||
public var m_inv_dt:Number;
|
||||
|
||||
public var m_islandFlag:Boolean;
|
||||
|
||||
public var m_collideConnected:Boolean;
|
||||
|
||||
public var m_userData:*;
|
||||
|
||||
public function b2Joint(param1:b2JointDef)
|
||||
{
|
||||
super();
|
||||
m_type = param1.type;
|
||||
m_prev = null;
|
||||
m_next = null;
|
||||
m_body1 = param1.body1;
|
||||
m_body2 = param1.body2;
|
||||
m_collideConnected = param1.collideConnected;
|
||||
m_islandFlag = false;
|
||||
m_userData = param1.userData;
|
||||
}
|
||||
|
||||
public static function Create(param1:b2JointDef, param2:*) : b2Joint
|
||||
{
|
||||
var _loc3_:b2Joint = null;
|
||||
switch(param1.type - 1)
|
||||
{
|
||||
case 0:
|
||||
_loc3_ = new b2RevoluteJoint(param1 as b2RevoluteJointDef);
|
||||
break;
|
||||
case 1:
|
||||
_loc3_ = new b2PrismaticJoint(param1 as b2PrismaticJointDef);
|
||||
break;
|
||||
case 2:
|
||||
_loc3_ = new b2DistanceJoint(param1 as b2DistanceJointDef);
|
||||
break;
|
||||
case 3:
|
||||
_loc3_ = new b2PulleyJoint(param1 as b2PulleyJointDef);
|
||||
break;
|
||||
case 4:
|
||||
_loc3_ = new b2MouseJoint(param1 as b2MouseJointDef);
|
||||
break;
|
||||
case 5:
|
||||
_loc3_ = new b2GearJoint(param1 as b2GearJointDef);
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function Destroy(param1:b2Joint, param2:*) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function GetType() : int
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
public function GetAnchor1() : b2Vec2
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetAnchor2() : b2Vec2
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetReactionForce() : b2Vec2
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function GetReactionTorque() : Number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function GetBody1() : b2Body
|
||||
{
|
||||
return m_body1;
|
||||
}
|
||||
|
||||
public function GetBody2() : b2Body
|
||||
{
|
||||
return m_body2;
|
||||
}
|
||||
|
||||
public function GetNext() : b2Joint
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
public function GetUserData() : *
|
||||
{
|
||||
return m_userData;
|
||||
}
|
||||
|
||||
public function SetUserData(param1:*) : void
|
||||
{
|
||||
m_userData = param1;
|
||||
}
|
||||
|
||||
public function InitVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function SolveVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function InitPositionConstraints() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function SolvePositionConstraints() : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Dynamics.b2Body;
|
||||
|
||||
public class b2JointDef
|
||||
{
|
||||
|
||||
public var type:int;
|
||||
|
||||
public var userData:*;
|
||||
|
||||
public var body1:b2Body;
|
||||
|
||||
public var body2:b2Body;
|
||||
|
||||
public var collideConnected:Boolean;
|
||||
|
||||
public function b2JointDef()
|
||||
{
|
||||
super();
|
||||
type = 0;
|
||||
userData = null;
|
||||
body1 = null;
|
||||
body2 = null;
|
||||
collideConnected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Dynamics.b2Body;
|
||||
|
||||
public class b2JointEdge
|
||||
{
|
||||
|
||||
public var other:b2Body;
|
||||
|
||||
public var joint:b2Joint;
|
||||
|
||||
public var prev:b2JointEdge;
|
||||
|
||||
public var next:b2JointEdge;
|
||||
|
||||
public function b2JointEdge()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Mat22;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import Box2D.Dynamics.b2TimeStep;
|
||||
|
||||
public class b2MouseJoint extends b2Joint
|
||||
{
|
||||
|
||||
private var K:b2Mat22 = new b2Mat22();
|
||||
|
||||
private var K1:b2Mat22 = new b2Mat22();
|
||||
|
||||
private var K2:b2Mat22 = new b2Mat22();
|
||||
|
||||
public var m_localAnchor:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_target:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_impulse:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_mass:b2Mat22 = new b2Mat22();
|
||||
|
||||
public var m_C:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_maxForce:Number;
|
||||
|
||||
public var m_beta:Number;
|
||||
|
||||
public var m_gamma:Number;
|
||||
|
||||
public function b2MouseJoint(param1:b2MouseJointDef)
|
||||
{
|
||||
super(param1);
|
||||
m_target.SetV(param1.target);
|
||||
var _loc2_:Number = m_target.x - m_body2.m_xf.position.x;
|
||||
var _loc4_:Number = m_target.y - m_body2.m_xf.position.y;
|
||||
var _loc6_:b2Mat22 = m_body2.m_xf.R;
|
||||
m_localAnchor.x = _loc2_ * _loc6_.col1.x + _loc4_ * _loc6_.col1.y;
|
||||
m_localAnchor.y = _loc2_ * _loc6_.col2.x + _loc4_ * _loc6_.col2.y;
|
||||
m_maxForce = param1.maxForce;
|
||||
m_impulse.SetZero();
|
||||
var _loc5_:Number = m_body2.m_mass;
|
||||
var _loc8_:Number = 2 * 3.141592653589793 * param1.frequencyHz;
|
||||
var _loc3_:Number = 2 * _loc5_ * param1.dampingRatio * _loc8_;
|
||||
var _loc7_:Number = param1.timeStep * _loc5_ * (_loc8_ * _loc8_);
|
||||
m_gamma = 1 / (_loc3_ + _loc7_);
|
||||
m_beta = _loc7_ / (_loc3_ + _loc7_);
|
||||
}
|
||||
|
||||
override public function GetAnchor1() : b2Vec2
|
||||
{
|
||||
return m_target;
|
||||
}
|
||||
|
||||
override public function GetAnchor2() : b2Vec2
|
||||
{
|
||||
return m_body2.GetWorldPoint(m_localAnchor);
|
||||
}
|
||||
|
||||
override public function GetReactionForce() : b2Vec2
|
||||
{
|
||||
return m_impulse;
|
||||
}
|
||||
|
||||
override public function GetReactionTorque() : Number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function SetTarget(param1:b2Vec2) : void
|
||||
{
|
||||
if(m_body2.IsSleeping())
|
||||
{
|
||||
m_body2.WakeUp();
|
||||
}
|
||||
m_target = param1;
|
||||
}
|
||||
|
||||
override public function InitVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc8_:b2Mat22 = null;
|
||||
var _loc2_:b2Body = m_body2;
|
||||
_loc8_ = _loc2_.m_xf.R;
|
||||
var _loc5_:Number = m_localAnchor.x - _loc2_.m_sweep.localCenter.x;
|
||||
var _loc6_:Number = m_localAnchor.y - _loc2_.m_sweep.localCenter.y;
|
||||
var _loc4_:Number = _loc8_.col1.x * _loc5_ + _loc8_.col2.x * _loc6_;
|
||||
_loc6_ = _loc8_.col1.y * _loc5_ + _loc8_.col2.y * _loc6_;
|
||||
_loc5_ = _loc4_;
|
||||
var _loc3_:Number = _loc2_.m_invMass;
|
||||
var _loc9_:Number = _loc2_.m_invI;
|
||||
K1.col1.x = _loc3_;
|
||||
K1.col2.x = 0;
|
||||
K1.col1.y = 0;
|
||||
K1.col2.y = _loc3_;
|
||||
K2.col1.x = _loc9_ * _loc6_ * _loc6_;
|
||||
K2.col2.x = -_loc9_ * _loc5_ * _loc6_;
|
||||
K2.col1.y = -_loc9_ * _loc5_ * _loc6_;
|
||||
K2.col2.y = _loc9_ * _loc5_ * _loc5_;
|
||||
K.SetM(K1);
|
||||
K.AddM(K2);
|
||||
K.col1.x += m_gamma;
|
||||
K.col2.y += m_gamma;
|
||||
K.Invert(m_mass);
|
||||
m_C.x = _loc2_.m_sweep.c.x + _loc5_ - m_target.x;
|
||||
m_C.y = _loc2_.m_sweep.c.y + _loc6_ - m_target.y;
|
||||
_loc2_.m_angularVelocity *= 0.98;
|
||||
var _loc7_:Number = param1.dt * m_impulse.x;
|
||||
var _loc10_:Number = param1.dt * m_impulse.y;
|
||||
_loc2_.m_linearVelocity.x += _loc3_ * _loc7_;
|
||||
_loc2_.m_linearVelocity.y += _loc3_ * _loc10_;
|
||||
_loc2_.m_angularVelocity += _loc9_ * (_loc5_ * _loc10_ - _loc6_ * _loc7_);
|
||||
}
|
||||
|
||||
override public function SolveVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc16_:b2Mat22 = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:Number = NaN;
|
||||
var _loc2_:b2Body = m_body2;
|
||||
_loc16_ = _loc2_.m_xf.R;
|
||||
var _loc5_:Number = m_localAnchor.x - _loc2_.m_sweep.localCenter.x;
|
||||
var _loc6_:Number = m_localAnchor.y - _loc2_.m_sweep.localCenter.y;
|
||||
_loc3_ = _loc16_.col1.x * _loc5_ + _loc16_.col2.x * _loc6_;
|
||||
_loc6_ = _loc16_.col1.y * _loc5_ + _loc16_.col2.y * _loc6_;
|
||||
_loc5_ = _loc3_;
|
||||
var _loc12_:Number = _loc2_.m_linearVelocity.x + -_loc2_.m_angularVelocity * _loc6_;
|
||||
var _loc11_:Number = _loc2_.m_linearVelocity.y + _loc2_.m_angularVelocity * _loc5_;
|
||||
_loc16_ = m_mass;
|
||||
_loc3_ = _loc12_ + m_beta * param1.inv_dt * m_C.x + m_gamma * param1.dt * m_impulse.x;
|
||||
_loc4_ = _loc11_ + m_beta * param1.inv_dt * m_C.y + m_gamma * param1.dt * m_impulse.y;
|
||||
var _loc14_:Number = -param1.inv_dt * (_loc16_.col1.x * _loc3_ + _loc16_.col2.x * _loc4_);
|
||||
var _loc13_:Number = -param1.inv_dt * (_loc16_.col1.y * _loc3_ + _loc16_.col2.y * _loc4_);
|
||||
var _loc9_:Number = m_impulse.x;
|
||||
var _loc10_:Number = m_impulse.y;
|
||||
m_impulse.x += _loc14_;
|
||||
m_impulse.y += _loc13_;
|
||||
var _loc15_:Number = m_impulse.Length();
|
||||
if(_loc15_ > m_maxForce)
|
||||
{
|
||||
m_impulse.Multiply(m_maxForce / _loc15_);
|
||||
}
|
||||
_loc14_ = m_impulse.x - _loc9_;
|
||||
_loc13_ = m_impulse.y - _loc10_;
|
||||
var _loc7_:Number = param1.dt * _loc14_;
|
||||
var _loc8_:Number = param1.dt * _loc13_;
|
||||
_loc2_.m_linearVelocity.x += _loc2_.m_invMass * _loc7_;
|
||||
_loc2_.m_linearVelocity.y += _loc2_.m_invMass * _loc8_;
|
||||
_loc2_.m_angularVelocity += _loc2_.m_invI * (_loc5_ * _loc8_ - _loc6_ * _loc7_);
|
||||
}
|
||||
|
||||
override public function SolvePositionConstraints() : Boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2MouseJointDef extends b2JointDef
|
||||
{
|
||||
|
||||
public var target:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var maxForce:Number;
|
||||
|
||||
public var frequencyHz:Number;
|
||||
|
||||
public var dampingRatio:Number;
|
||||
|
||||
public var timeStep:Number;
|
||||
|
||||
public function b2MouseJointDef()
|
||||
{
|
||||
super();
|
||||
type = 5;
|
||||
maxForce = 0;
|
||||
frequencyHz = 5;
|
||||
dampingRatio = 0.7;
|
||||
timeStep = 0.016666666666666666;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,534 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Mat22;
|
||||
import Box2D.Common.Math.b2Math;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import Box2D.Dynamics.b2TimeStep;
|
||||
|
||||
public class b2PrismaticJoint extends b2Joint
|
||||
{
|
||||
|
||||
public var m_localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localXAxis1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localYAxis1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_refAngle:Number;
|
||||
|
||||
public var m_linearJacobian:b2Jacobian = new b2Jacobian();
|
||||
|
||||
public var m_linearMass:Number;
|
||||
|
||||
public var m_force:Number;
|
||||
|
||||
public var m_angularMass:Number;
|
||||
|
||||
public var m_torque:Number;
|
||||
|
||||
public var m_motorJacobian:b2Jacobian = new b2Jacobian();
|
||||
|
||||
public var m_motorMass:Number;
|
||||
|
||||
public var m_motorForce:Number;
|
||||
|
||||
public var m_limitForce:Number;
|
||||
|
||||
public var m_limitPositionImpulse:Number;
|
||||
|
||||
public var m_lowerTranslation:Number;
|
||||
|
||||
public var m_upperTranslation:Number;
|
||||
|
||||
public var m_maxMotorForce:Number;
|
||||
|
||||
public var m_motorSpeed:Number;
|
||||
|
||||
public var m_enableLimit:Boolean;
|
||||
|
||||
public var m_enableMotor:Boolean;
|
||||
|
||||
public var m_limitState:int;
|
||||
|
||||
public function b2PrismaticJoint(param1:b2PrismaticJointDef)
|
||||
{
|
||||
var _loc4_:* = null;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
super(param1);
|
||||
m_localAnchor1.SetV(param1.localAnchor1);
|
||||
m_localAnchor2.SetV(param1.localAnchor2);
|
||||
m_localXAxis1.SetV(param1.localAxis1);
|
||||
m_localYAxis1.x = -m_localXAxis1.y;
|
||||
m_localYAxis1.y = m_localXAxis1.x;
|
||||
m_refAngle = param1.referenceAngle;
|
||||
m_linearJacobian.SetZero();
|
||||
m_linearMass = 0;
|
||||
m_force = 0;
|
||||
m_angularMass = 0;
|
||||
m_torque = 0;
|
||||
m_motorJacobian.SetZero();
|
||||
m_motorMass = 0;
|
||||
m_motorForce = 0;
|
||||
m_limitForce = 0;
|
||||
m_limitPositionImpulse = 0;
|
||||
m_lowerTranslation = param1.lowerTranslation;
|
||||
m_upperTranslation = param1.upperTranslation;
|
||||
m_maxMotorForce = param1.maxMotorForce;
|
||||
m_motorSpeed = param1.motorSpeed;
|
||||
m_enableLimit = param1.enableLimit;
|
||||
m_enableMotor = param1.enableMotor;
|
||||
}
|
||||
|
||||
override public function GetAnchor1() : b2Vec2
|
||||
{
|
||||
return m_body1.GetWorldPoint(m_localAnchor1);
|
||||
}
|
||||
|
||||
override public function GetAnchor2() : b2Vec2
|
||||
{
|
||||
return m_body2.GetWorldPoint(m_localAnchor2);
|
||||
}
|
||||
|
||||
override public function GetReactionForce() : b2Vec2
|
||||
{
|
||||
var _loc4_:b2Mat22 = m_body1.m_xf.R;
|
||||
var _loc3_:Number = m_limitForce * (_loc4_.col1.x * m_localXAxis1.x + _loc4_.col2.x * m_localXAxis1.y);
|
||||
var _loc1_:Number = m_limitForce * (_loc4_.col1.y * m_localXAxis1.x + _loc4_.col2.y * m_localXAxis1.y);
|
||||
var _loc2_:Number = m_force * (_loc4_.col1.x * m_localYAxis1.x + _loc4_.col2.x * m_localYAxis1.y);
|
||||
var _loc5_:Number = m_force * (_loc4_.col1.y * m_localYAxis1.x + _loc4_.col2.y * m_localYAxis1.y);
|
||||
return new b2Vec2(m_limitForce * _loc3_ + m_force * _loc2_,m_limitForce * _loc1_ + m_force * _loc5_);
|
||||
}
|
||||
|
||||
override public function GetReactionTorque() : Number
|
||||
{
|
||||
return m_torque;
|
||||
}
|
||||
|
||||
public function GetJointTranslation() : Number
|
||||
{
|
||||
var _loc7_:* = null;
|
||||
var _loc9_:b2Body = m_body1;
|
||||
var _loc1_:b2Body = m_body2;
|
||||
var _loc2_:b2Vec2 = _loc9_.GetWorldPoint(m_localAnchor1);
|
||||
var _loc3_:b2Vec2 = _loc1_.GetWorldPoint(m_localAnchor2);
|
||||
var _loc4_:Number = _loc3_.x - _loc2_.x;
|
||||
var _loc5_:Number = _loc3_.y - _loc2_.y;
|
||||
var _loc8_:b2Vec2 = _loc9_.GetWorldVector(m_localXAxis1);
|
||||
return _loc8_.x * _loc4_ + _loc8_.y * _loc5_;
|
||||
}
|
||||
|
||||
public function GetJointSpeed() : Number
|
||||
{
|
||||
var _loc13_:b2Mat22 = null;
|
||||
var _loc4_:b2Body = m_body1;
|
||||
var _loc5_:b2Body = m_body2;
|
||||
_loc13_ = _loc4_.m_xf.R;
|
||||
var _loc11_:Number = m_localAnchor1.x - _loc4_.m_sweep.localCenter.x;
|
||||
var _loc17_:Number = m_localAnchor1.y - _loc4_.m_sweep.localCenter.y;
|
||||
var _loc1_:Number = _loc13_.col1.x * _loc11_ + _loc13_.col2.x * _loc17_;
|
||||
_loc17_ = _loc13_.col1.y * _loc11_ + _loc13_.col2.y * _loc17_;
|
||||
_loc11_ = _loc1_;
|
||||
_loc13_ = _loc5_.m_xf.R;
|
||||
var _loc14_:Number = m_localAnchor2.x - _loc5_.m_sweep.localCenter.x;
|
||||
var _loc12_:Number = m_localAnchor2.y - _loc5_.m_sweep.localCenter.y;
|
||||
_loc1_ = _loc13_.col1.x * _loc14_ + _loc13_.col2.x * _loc12_;
|
||||
_loc12_ = _loc13_.col1.y * _loc14_ + _loc13_.col2.y * _loc12_;
|
||||
_loc14_ = _loc1_;
|
||||
var _loc8_:Number = _loc4_.m_sweep.c.x + _loc11_;
|
||||
var _loc15_:Number = _loc4_.m_sweep.c.y + _loc17_;
|
||||
var _loc10_:Number = _loc5_.m_sweep.c.x + _loc14_;
|
||||
var _loc9_:Number = _loc5_.m_sweep.c.y + _loc12_;
|
||||
var _loc6_:Number = _loc10_ - _loc8_;
|
||||
var _loc7_:Number = _loc9_ - _loc15_;
|
||||
var _loc2_:b2Vec2 = _loc4_.GetWorldVector(m_localXAxis1);
|
||||
var _loc18_:b2Vec2 = _loc4_.m_linearVelocity;
|
||||
var _loc20_:b2Vec2 = _loc5_.m_linearVelocity;
|
||||
var _loc16_:Number = _loc4_.m_angularVelocity;
|
||||
var _loc19_:Number = _loc5_.m_angularVelocity;
|
||||
return _loc6_ * (-_loc16_ * _loc2_.y) + _loc7_ * (_loc16_ * _loc2_.x) + (_loc2_.x * (_loc20_.x + -_loc19_ * _loc12_ - _loc18_.x - -_loc16_ * _loc17_) + _loc2_.y * (_loc20_.y + _loc19_ * _loc14_ - _loc18_.y - _loc16_ * _loc11_));
|
||||
}
|
||||
|
||||
public function IsLimitEnabled() : Boolean
|
||||
{
|
||||
return m_enableLimit;
|
||||
}
|
||||
|
||||
public function EnableLimit(param1:Boolean) : void
|
||||
{
|
||||
m_enableLimit = param1;
|
||||
}
|
||||
|
||||
public function GetLowerLimit() : Number
|
||||
{
|
||||
return m_lowerTranslation;
|
||||
}
|
||||
|
||||
public function GetUpperLimit() : Number
|
||||
{
|
||||
return m_upperTranslation;
|
||||
}
|
||||
|
||||
public function SetLimits(param1:Number, param2:Number) : void
|
||||
{
|
||||
m_lowerTranslation = param1;
|
||||
m_upperTranslation = param2;
|
||||
}
|
||||
|
||||
public function IsMotorEnabled() : Boolean
|
||||
{
|
||||
return m_enableMotor;
|
||||
}
|
||||
|
||||
public function EnableMotor(param1:Boolean) : void
|
||||
{
|
||||
m_enableMotor = param1;
|
||||
}
|
||||
|
||||
public function SetMotorSpeed(param1:Number) : void
|
||||
{
|
||||
m_motorSpeed = param1;
|
||||
}
|
||||
|
||||
public function GetMotorSpeed() : Number
|
||||
{
|
||||
return m_motorSpeed;
|
||||
}
|
||||
|
||||
public function SetMaxMotorForce(param1:Number) : void
|
||||
{
|
||||
m_maxMotorForce = param1;
|
||||
}
|
||||
|
||||
public function GetMotorForce() : Number
|
||||
{
|
||||
return m_motorForce;
|
||||
}
|
||||
|
||||
override public function InitVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc27_:b2Mat22 = null;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc26_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc24_:Number = NaN;
|
||||
var _loc23_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc6_:b2Body = m_body1;
|
||||
var _loc7_:b2Body = m_body2;
|
||||
_loc27_ = _loc6_.m_xf.R;
|
||||
var _loc25_:Number = m_localAnchor1.x - _loc6_.m_sweep.localCenter.x;
|
||||
var _loc28_:Number = m_localAnchor1.y - _loc6_.m_sweep.localCenter.y;
|
||||
_loc17_ = _loc27_.col1.x * _loc25_ + _loc27_.col2.x * _loc28_;
|
||||
_loc28_ = _loc27_.col1.y * _loc25_ + _loc27_.col2.y * _loc28_;
|
||||
_loc25_ = _loc17_;
|
||||
_loc27_ = _loc7_.m_xf.R;
|
||||
var _loc15_:Number = m_localAnchor2.x - _loc7_.m_sweep.localCenter.x;
|
||||
var _loc14_:Number = m_localAnchor2.y - _loc7_.m_sweep.localCenter.y;
|
||||
_loc17_ = _loc27_.col1.x * _loc15_ + _loc27_.col2.x * _loc14_;
|
||||
_loc14_ = _loc27_.col1.y * _loc15_ + _loc27_.col2.y * _loc14_;
|
||||
_loc15_ = _loc17_;
|
||||
var _loc5_:Number = _loc6_.m_invMass;
|
||||
var _loc3_:Number = _loc7_.m_invMass;
|
||||
var _loc4_:Number = _loc6_.m_invI;
|
||||
var _loc2_:Number = _loc7_.m_invI;
|
||||
_loc27_ = _loc6_.m_xf.R;
|
||||
var _loc8_:Number = _loc27_.col1.x * m_localYAxis1.x + _loc27_.col2.x * m_localYAxis1.y;
|
||||
var _loc20_:Number = _loc27_.col1.y * m_localYAxis1.x + _loc27_.col2.y * m_localYAxis1.y;
|
||||
var _loc10_:Number = _loc7_.m_sweep.c.x + _loc15_ - _loc6_.m_sweep.c.x;
|
||||
var _loc12_:Number = _loc7_.m_sweep.c.y + _loc14_ - _loc6_.m_sweep.c.y;
|
||||
m_linearJacobian.linear1.x = -_loc8_;
|
||||
m_linearJacobian.linear1.y = -_loc20_;
|
||||
m_linearJacobian.linear2.x = _loc8_;
|
||||
m_linearJacobian.linear2.y = _loc20_;
|
||||
m_linearJacobian.angular1 = -(_loc10_ * _loc20_ - _loc12_ * _loc8_);
|
||||
m_linearJacobian.angular2 = _loc15_ * _loc20_ - _loc14_ * _loc8_;
|
||||
m_linearMass = _loc5_ + _loc4_ * m_linearJacobian.angular1 * m_linearJacobian.angular1 + _loc3_ + _loc2_ * m_linearJacobian.angular2 * m_linearJacobian.angular2;
|
||||
m_linearMass = 1 / m_linearMass;
|
||||
m_angularMass = _loc4_ + _loc2_;
|
||||
if(m_angularMass > Number.MIN_VALUE)
|
||||
{
|
||||
m_angularMass = 1 / m_angularMass;
|
||||
}
|
||||
if(m_enableLimit || m_enableMotor)
|
||||
{
|
||||
_loc27_ = _loc6_.m_xf.R;
|
||||
_loc11_ = _loc27_.col1.x * m_localXAxis1.x + _loc27_.col2.x * m_localXAxis1.y;
|
||||
_loc9_ = _loc27_.col1.y * m_localXAxis1.x + _loc27_.col2.y * m_localXAxis1.y;
|
||||
m_motorJacobian.linear1.x = -_loc11_;
|
||||
m_motorJacobian.linear1.y = -_loc9_;
|
||||
m_motorJacobian.linear2.x = _loc11_;
|
||||
m_motorJacobian.linear2.y = _loc9_;
|
||||
m_motorJacobian.angular1 = -(_loc10_ * _loc9_ - _loc12_ * _loc11_);
|
||||
m_motorJacobian.angular2 = _loc15_ * _loc9_ - _loc14_ * _loc11_;
|
||||
m_motorMass = _loc5_ + _loc4_ * m_motorJacobian.angular1 * m_motorJacobian.angular1 + _loc3_ + _loc2_ * m_motorJacobian.angular2 * m_motorJacobian.angular2;
|
||||
m_motorMass = 1 / m_motorMass;
|
||||
if(m_enableLimit)
|
||||
{
|
||||
_loc21_ = _loc10_ - _loc25_;
|
||||
_loc22_ = _loc12_ - _loc28_;
|
||||
_loc26_ = _loc11_ * _loc21_ + _loc9_ * _loc22_;
|
||||
if(b2Math.b2Abs(m_upperTranslation - m_lowerTranslation) < 2 * 0.005)
|
||||
{
|
||||
m_limitState = 3;
|
||||
}
|
||||
else if(_loc26_ <= m_lowerTranslation)
|
||||
{
|
||||
if(m_limitState != 1)
|
||||
{
|
||||
m_limitForce = 0;
|
||||
}
|
||||
m_limitState = 1;
|
||||
}
|
||||
else if(_loc26_ >= m_upperTranslation)
|
||||
{
|
||||
if(m_limitState != 2)
|
||||
{
|
||||
m_limitForce = 0;
|
||||
}
|
||||
m_limitState = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_limitState = 0;
|
||||
m_limitForce = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(m_enableMotor == false)
|
||||
{
|
||||
m_motorForce = 0;
|
||||
}
|
||||
if(m_enableLimit == false)
|
||||
{
|
||||
m_limitForce = 0;
|
||||
}
|
||||
if(param1.warmStarting)
|
||||
{
|
||||
_loc13_ = param1.dt * (m_force * m_linearJacobian.linear1.x + (m_motorForce + m_limitForce) * m_motorJacobian.linear1.x);
|
||||
_loc16_ = param1.dt * (m_force * m_linearJacobian.linear1.y + (m_motorForce + m_limitForce) * m_motorJacobian.linear1.y);
|
||||
_loc24_ = param1.dt * (m_force * m_linearJacobian.linear2.x + (m_motorForce + m_limitForce) * m_motorJacobian.linear2.x);
|
||||
_loc23_ = param1.dt * (m_force * m_linearJacobian.linear2.y + (m_motorForce + m_limitForce) * m_motorJacobian.linear2.y);
|
||||
_loc18_ = param1.dt * (m_force * m_linearJacobian.angular1 - m_torque + (m_motorForce + m_limitForce) * m_motorJacobian.angular1);
|
||||
_loc19_ = param1.dt * (m_force * m_linearJacobian.angular2 + m_torque + (m_motorForce + m_limitForce) * m_motorJacobian.angular2);
|
||||
_loc6_.m_linearVelocity.x += _loc5_ * _loc13_;
|
||||
_loc6_.m_linearVelocity.y += _loc5_ * _loc16_;
|
||||
_loc6_.m_angularVelocity += _loc4_ * _loc18_;
|
||||
_loc7_.m_linearVelocity.x += _loc3_ * _loc24_;
|
||||
_loc7_.m_linearVelocity.y += _loc3_ * _loc23_;
|
||||
_loc7_.m_angularVelocity += _loc2_ * _loc19_;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_force = 0;
|
||||
m_torque = 0;
|
||||
m_limitForce = 0;
|
||||
m_motorForce = 0;
|
||||
}
|
||||
m_limitPositionImpulse = 0;
|
||||
}
|
||||
|
||||
override public function SolveVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc9_:b2Body = m_body1;
|
||||
var _loc10_:b2Body = m_body2;
|
||||
var _loc5_:Number = _loc9_.m_invMass;
|
||||
var _loc3_:Number = _loc10_.m_invMass;
|
||||
var _loc4_:Number = _loc9_.m_invI;
|
||||
var _loc2_:Number = _loc10_.m_invI;
|
||||
var _loc18_:Number = m_linearJacobian.Compute(_loc9_.m_linearVelocity,_loc9_.m_angularVelocity,_loc10_.m_linearVelocity,_loc10_.m_angularVelocity);
|
||||
var _loc17_:Number = -param1.inv_dt * m_linearMass * _loc18_;
|
||||
m_force += _loc17_;
|
||||
var _loc11_:Number = param1.dt * _loc17_;
|
||||
_loc9_.m_linearVelocity.x += _loc5_ * _loc11_ * m_linearJacobian.linear1.x;
|
||||
_loc9_.m_linearVelocity.y += _loc5_ * _loc11_ * m_linearJacobian.linear1.y;
|
||||
_loc9_.m_angularVelocity += _loc4_ * _loc11_ * m_linearJacobian.angular1;
|
||||
_loc10_.m_linearVelocity.x += _loc3_ * _loc11_ * m_linearJacobian.linear2.x;
|
||||
_loc10_.m_linearVelocity.y += _loc3_ * _loc11_ * m_linearJacobian.linear2.y;
|
||||
_loc10_.m_angularVelocity += _loc2_ * _loc11_ * m_linearJacobian.angular2;
|
||||
var _loc19_:Number = _loc10_.m_angularVelocity - _loc9_.m_angularVelocity;
|
||||
var _loc6_:Number = -param1.inv_dt * m_angularMass * _loc19_;
|
||||
m_torque += _loc6_;
|
||||
var _loc7_:Number = param1.dt * _loc6_;
|
||||
_loc9_.m_angularVelocity -= _loc4_ * _loc7_;
|
||||
_loc10_.m_angularVelocity += _loc2_ * _loc7_;
|
||||
if(m_enableMotor && m_limitState != 3)
|
||||
{
|
||||
_loc16_ = m_motorJacobian.Compute(_loc9_.m_linearVelocity,_loc9_.m_angularVelocity,_loc10_.m_linearVelocity,_loc10_.m_angularVelocity) - m_motorSpeed;
|
||||
_loc15_ = -param1.inv_dt * m_motorMass * _loc16_;
|
||||
_loc12_ = m_motorForce;
|
||||
m_motorForce = b2Math.b2Clamp(m_motorForce + _loc15_,-m_maxMotorForce,m_maxMotorForce);
|
||||
_loc15_ = m_motorForce - _loc12_;
|
||||
_loc11_ = param1.dt * _loc15_;
|
||||
_loc9_.m_linearVelocity.x += _loc5_ * _loc11_ * m_motorJacobian.linear1.x;
|
||||
_loc9_.m_linearVelocity.y += _loc5_ * _loc11_ * m_motorJacobian.linear1.y;
|
||||
_loc9_.m_angularVelocity += _loc4_ * _loc11_ * m_motorJacobian.angular1;
|
||||
_loc10_.m_linearVelocity.x += _loc3_ * _loc11_ * m_motorJacobian.linear2.x;
|
||||
_loc10_.m_linearVelocity.y += _loc3_ * _loc11_ * m_motorJacobian.linear2.y;
|
||||
_loc10_.m_angularVelocity += _loc2_ * _loc11_ * m_motorJacobian.angular2;
|
||||
}
|
||||
if(m_enableLimit && m_limitState != 0)
|
||||
{
|
||||
_loc13_ = m_motorJacobian.Compute(_loc9_.m_linearVelocity,_loc9_.m_angularVelocity,_loc10_.m_linearVelocity,_loc10_.m_angularVelocity);
|
||||
_loc8_ = -param1.inv_dt * m_motorMass * _loc13_;
|
||||
if(m_limitState == 3)
|
||||
{
|
||||
m_limitForce += _loc8_;
|
||||
}
|
||||
else if(m_limitState == 1)
|
||||
{
|
||||
_loc14_ = m_limitForce;
|
||||
m_limitForce = b2Math.b2Max(m_limitForce + _loc8_,0);
|
||||
_loc8_ = m_limitForce - _loc14_;
|
||||
}
|
||||
else if(m_limitState == 2)
|
||||
{
|
||||
_loc14_ = m_limitForce;
|
||||
m_limitForce = b2Math.b2Min(m_limitForce + _loc8_,0);
|
||||
_loc8_ = m_limitForce - _loc14_;
|
||||
}
|
||||
_loc11_ = param1.dt * _loc8_;
|
||||
_loc9_.m_linearVelocity.x += _loc5_ * _loc11_ * m_motorJacobian.linear1.x;
|
||||
_loc9_.m_linearVelocity.y += _loc5_ * _loc11_ * m_motorJacobian.linear1.y;
|
||||
_loc9_.m_angularVelocity += _loc4_ * _loc11_ * m_motorJacobian.angular1;
|
||||
_loc10_.m_linearVelocity.x += _loc3_ * _loc11_ * m_motorJacobian.linear2.x;
|
||||
_loc10_.m_linearVelocity.y += _loc3_ * _loc11_ * m_motorJacobian.linear2.y;
|
||||
_loc10_.m_angularVelocity += _loc2_ * _loc11_ * m_motorJacobian.angular2;
|
||||
}
|
||||
}
|
||||
|
||||
override public function SolvePositionConstraints() : Boolean
|
||||
{
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc29_:b2Mat22 = null;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc28_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc8_:b2Body = m_body1;
|
||||
var _loc9_:b2Body = m_body2;
|
||||
var _loc5_:Number = _loc8_.m_invMass;
|
||||
var _loc2_:Number = _loc9_.m_invMass;
|
||||
var _loc3_:Number = _loc8_.m_invI;
|
||||
var _loc1_:Number = _loc9_.m_invI;
|
||||
_loc29_ = _loc8_.m_xf.R;
|
||||
var _loc27_:Number = m_localAnchor1.x - _loc8_.m_sweep.localCenter.x;
|
||||
var _loc31_:Number = m_localAnchor1.y - _loc8_.m_sweep.localCenter.y;
|
||||
_loc19_ = _loc29_.col1.x * _loc27_ + _loc29_.col2.x * _loc31_;
|
||||
_loc31_ = _loc29_.col1.y * _loc27_ + _loc29_.col2.y * _loc31_;
|
||||
_loc27_ = _loc19_;
|
||||
_loc29_ = _loc9_.m_xf.R;
|
||||
var _loc17_:Number = m_localAnchor2.x - _loc9_.m_sweep.localCenter.x;
|
||||
var _loc16_:Number = m_localAnchor2.y - _loc9_.m_sweep.localCenter.y;
|
||||
_loc19_ = _loc29_.col1.x * _loc17_ + _loc29_.col2.x * _loc16_;
|
||||
_loc16_ = _loc29_.col1.y * _loc17_ + _loc29_.col2.y * _loc16_;
|
||||
_loc17_ = _loc19_;
|
||||
var _loc26_:Number = _loc8_.m_sweep.c.x + _loc27_;
|
||||
var _loc30_:Number = _loc8_.m_sweep.c.y + _loc31_;
|
||||
var _loc15_:Number = _loc9_.m_sweep.c.x + _loc17_;
|
||||
var _loc14_:Number = _loc9_.m_sweep.c.y + _loc16_;
|
||||
var _loc23_:Number = _loc15_ - _loc26_;
|
||||
var _loc24_:Number = _loc14_ - _loc30_;
|
||||
_loc29_ = _loc8_.m_xf.R;
|
||||
var _loc10_:Number = _loc29_.col1.x * m_localYAxis1.x + _loc29_.col2.x * m_localYAxis1.y;
|
||||
var _loc21_:Number = _loc29_.col1.y * m_localYAxis1.x + _loc29_.col2.y * m_localYAxis1.y;
|
||||
var _loc25_:Number = _loc10_ * _loc23_ + _loc21_ * _loc24_;
|
||||
_loc25_ = b2Math.b2Clamp(_loc25_,-0.2,0.2);
|
||||
var _loc7_:Number = -m_linearMass * _loc25_;
|
||||
_loc8_.m_sweep.c.x += _loc5_ * _loc7_ * m_linearJacobian.linear1.x;
|
||||
_loc8_.m_sweep.c.y += _loc5_ * _loc7_ * m_linearJacobian.linear1.y;
|
||||
_loc8_.m_sweep.a += _loc3_ * _loc7_ * m_linearJacobian.angular1;
|
||||
_loc9_.m_sweep.c.x += _loc2_ * _loc7_ * m_linearJacobian.linear2.x;
|
||||
_loc9_.m_sweep.c.y += _loc2_ * _loc7_ * m_linearJacobian.linear2.y;
|
||||
_loc9_.m_sweep.a += _loc1_ * _loc7_ * m_linearJacobian.angular2;
|
||||
var _loc4_:Number = b2Math.b2Abs(_loc25_);
|
||||
var _loc6_:Number = _loc9_.m_sweep.a - _loc8_.m_sweep.a - m_refAngle;
|
||||
_loc6_ = b2Math.b2Clamp(_loc6_,-0.13962634015954636,0.13962634015954636);
|
||||
var _loc32_:Number = -m_angularMass * _loc6_;
|
||||
_loc8_.m_sweep.a -= _loc8_.m_invI * _loc32_;
|
||||
_loc9_.m_sweep.a += _loc9_.m_invI * _loc32_;
|
||||
_loc8_.SynchronizeTransform();
|
||||
_loc9_.SynchronizeTransform();
|
||||
var _loc20_:Number = b2Math.b2Abs(_loc6_);
|
||||
if(m_enableLimit && m_limitState != 0)
|
||||
{
|
||||
_loc29_ = _loc8_.m_xf.R;
|
||||
_loc27_ = m_localAnchor1.x - _loc8_.m_sweep.localCenter.x;
|
||||
_loc31_ = m_localAnchor1.y - _loc8_.m_sweep.localCenter.y;
|
||||
_loc19_ = _loc29_.col1.x * _loc27_ + _loc29_.col2.x * _loc31_;
|
||||
_loc31_ = _loc29_.col1.y * _loc27_ + _loc29_.col2.y * _loc31_;
|
||||
_loc27_ = _loc19_;
|
||||
_loc29_ = _loc9_.m_xf.R;
|
||||
_loc17_ = m_localAnchor2.x - _loc9_.m_sweep.localCenter.x;
|
||||
_loc16_ = m_localAnchor2.y - _loc9_.m_sweep.localCenter.y;
|
||||
_loc19_ = _loc29_.col1.x * _loc17_ + _loc29_.col2.x * _loc16_;
|
||||
_loc16_ = _loc29_.col1.y * _loc17_ + _loc29_.col2.y * _loc16_;
|
||||
_loc17_ = _loc19_;
|
||||
_loc26_ = _loc8_.m_sweep.c.x + _loc27_;
|
||||
_loc30_ = _loc8_.m_sweep.c.y + _loc31_;
|
||||
_loc15_ = _loc9_.m_sweep.c.x + _loc17_;
|
||||
_loc14_ = _loc9_.m_sweep.c.y + _loc16_;
|
||||
_loc23_ = _loc15_ - _loc26_;
|
||||
_loc24_ = _loc14_ - _loc30_;
|
||||
_loc29_ = _loc8_.m_xf.R;
|
||||
_loc12_ = _loc29_.col1.x * m_localXAxis1.x + _loc29_.col2.x * m_localXAxis1.y;
|
||||
_loc11_ = _loc29_.col1.y * m_localXAxis1.x + _loc29_.col2.y * m_localXAxis1.y;
|
||||
_loc28_ = _loc12_ * _loc23_ + _loc11_ * _loc24_;
|
||||
_loc18_ = 0;
|
||||
if(m_limitState == 3)
|
||||
{
|
||||
_loc22_ = b2Math.b2Clamp(_loc28_,-0.2,0.2);
|
||||
_loc18_ = -m_motorMass * _loc22_;
|
||||
_loc4_ = b2Math.b2Max(_loc4_,b2Math.b2Abs(_loc6_));
|
||||
}
|
||||
else if(m_limitState == 1)
|
||||
{
|
||||
_loc22_ = _loc28_ - m_lowerTranslation;
|
||||
_loc4_ = b2Math.b2Max(_loc4_,-_loc22_);
|
||||
_loc22_ = b2Math.b2Clamp(_loc22_ + 0.005,-0.2,0);
|
||||
_loc18_ = -m_motorMass * _loc22_;
|
||||
_loc13_ = m_limitPositionImpulse;
|
||||
m_limitPositionImpulse = b2Math.b2Max(m_limitPositionImpulse + _loc18_,0);
|
||||
_loc18_ = m_limitPositionImpulse - _loc13_;
|
||||
}
|
||||
else if(m_limitState == 2)
|
||||
{
|
||||
_loc22_ = _loc28_ - m_upperTranslation;
|
||||
_loc4_ = b2Math.b2Max(_loc4_,_loc22_);
|
||||
_loc22_ = b2Math.b2Clamp(_loc22_ - 0.005,0,0.2);
|
||||
_loc18_ = -m_motorMass * _loc22_;
|
||||
_loc13_ = m_limitPositionImpulse;
|
||||
m_limitPositionImpulse = b2Math.b2Min(m_limitPositionImpulse + _loc18_,0);
|
||||
_loc18_ = m_limitPositionImpulse - _loc13_;
|
||||
}
|
||||
_loc8_.m_sweep.c.x += _loc5_ * _loc18_ * m_motorJacobian.linear1.x;
|
||||
_loc8_.m_sweep.c.y += _loc5_ * _loc18_ * m_motorJacobian.linear1.y;
|
||||
_loc8_.m_sweep.a += _loc3_ * _loc18_ * m_motorJacobian.angular1;
|
||||
_loc9_.m_sweep.c.x += _loc2_ * _loc18_ * m_motorJacobian.linear2.x;
|
||||
_loc9_.m_sweep.c.y += _loc2_ * _loc18_ * m_motorJacobian.linear2.y;
|
||||
_loc9_.m_sweep.a += _loc1_ * _loc18_ * m_motorJacobian.angular2;
|
||||
_loc8_.SynchronizeTransform();
|
||||
_loc9_.SynchronizeTransform();
|
||||
}
|
||||
return _loc4_ <= 0.005 && _loc20_ <= 0.03490658503988659;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
|
||||
public class b2PrismaticJointDef extends b2JointDef
|
||||
{
|
||||
|
||||
public var localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var localAxis1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var referenceAngle:Number;
|
||||
|
||||
public var enableLimit:Boolean;
|
||||
|
||||
public var lowerTranslation:Number;
|
||||
|
||||
public var upperTranslation:Number;
|
||||
|
||||
public var enableMotor:Boolean;
|
||||
|
||||
public var maxMotorForce:Number;
|
||||
|
||||
public var motorSpeed:Number;
|
||||
|
||||
public function b2PrismaticJointDef()
|
||||
{
|
||||
super();
|
||||
type = 2;
|
||||
localAxis1.Set(1,0);
|
||||
referenceAngle = 0;
|
||||
enableLimit = false;
|
||||
lowerTranslation = 0;
|
||||
upperTranslation = 0;
|
||||
enableMotor = false;
|
||||
maxMotorForce = 0;
|
||||
motorSpeed = 0;
|
||||
}
|
||||
|
||||
public function Initialize(param1:b2Body, param2:b2Body, param3:b2Vec2, param4:b2Vec2) : void
|
||||
{
|
||||
body1 = param1;
|
||||
body2 = param2;
|
||||
localAnchor1 = body1.GetLocalPoint(param3);
|
||||
localAnchor2 = body2.GetLocalPoint(param3);
|
||||
localAxis1 = body1.GetLocalVector(param4);
|
||||
referenceAngle = body2.GetAngle() - body1.GetAngle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,491 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Mat22;
|
||||
import Box2D.Common.Math.b2Math;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import Box2D.Dynamics.b2TimeStep;
|
||||
|
||||
public class b2PulleyJoint extends b2Joint
|
||||
{
|
||||
|
||||
public static const b2_minPulleyLength:Number = 2;
|
||||
|
||||
public var m_ground:b2Body;
|
||||
|
||||
public var m_groundAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_groundAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_u1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_u2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_constant:Number;
|
||||
|
||||
public var m_ratio:Number;
|
||||
|
||||
public var m_maxLength1:Number;
|
||||
|
||||
public var m_maxLength2:Number;
|
||||
|
||||
public var m_pulleyMass:Number;
|
||||
|
||||
public var m_limitMass1:Number;
|
||||
|
||||
public var m_limitMass2:Number;
|
||||
|
||||
public var m_force:Number;
|
||||
|
||||
public var m_limitForce1:Number;
|
||||
|
||||
public var m_limitForce2:Number;
|
||||
|
||||
public var m_positionImpulse:Number;
|
||||
|
||||
public var m_limitPositionImpulse1:Number;
|
||||
|
||||
public var m_limitPositionImpulse2:Number;
|
||||
|
||||
public var m_state:int;
|
||||
|
||||
public var m_limitState1:int;
|
||||
|
||||
public var m_limitState2:int;
|
||||
|
||||
public function b2PulleyJoint(param1:b2PulleyJointDef)
|
||||
{
|
||||
var _loc4_:* = null;
|
||||
var _loc2_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
super(param1);
|
||||
m_ground = m_body1.m_world.m_groundBody;
|
||||
m_groundAnchor1.x = param1.groundAnchor1.x - m_ground.m_xf.position.x;
|
||||
m_groundAnchor1.y = param1.groundAnchor1.y - m_ground.m_xf.position.y;
|
||||
m_groundAnchor2.x = param1.groundAnchor2.x - m_ground.m_xf.position.x;
|
||||
m_groundAnchor2.y = param1.groundAnchor2.y - m_ground.m_xf.position.y;
|
||||
m_localAnchor1.SetV(param1.localAnchor1);
|
||||
m_localAnchor2.SetV(param1.localAnchor2);
|
||||
m_ratio = param1.ratio;
|
||||
m_constant = param1.length1 + m_ratio * param1.length2;
|
||||
m_maxLength1 = b2Math.b2Min(param1.maxLength1,m_constant - m_ratio * 2);
|
||||
m_maxLength2 = b2Math.b2Min(param1.maxLength2,(m_constant - 2) / m_ratio);
|
||||
m_force = 0;
|
||||
m_limitForce1 = 0;
|
||||
m_limitForce2 = 0;
|
||||
}
|
||||
|
||||
override public function GetAnchor1() : b2Vec2
|
||||
{
|
||||
return m_body1.GetWorldPoint(m_localAnchor1);
|
||||
}
|
||||
|
||||
override public function GetAnchor2() : b2Vec2
|
||||
{
|
||||
return m_body2.GetWorldPoint(m_localAnchor2);
|
||||
}
|
||||
|
||||
override public function GetReactionForce() : b2Vec2
|
||||
{
|
||||
var _loc1_:b2Vec2 = m_u2.Copy();
|
||||
_loc1_.Multiply(m_force);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
override public function GetReactionTorque() : Number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function GetGroundAnchor1() : b2Vec2
|
||||
{
|
||||
var _loc1_:b2Vec2 = m_ground.m_xf.position.Copy();
|
||||
_loc1_.Add(m_groundAnchor1);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function GetGroundAnchor2() : b2Vec2
|
||||
{
|
||||
var _loc1_:b2Vec2 = m_ground.m_xf.position.Copy();
|
||||
_loc1_.Add(m_groundAnchor2);
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function GetLength1() : Number
|
||||
{
|
||||
var _loc1_:b2Vec2 = m_body1.GetWorldPoint(m_localAnchor1);
|
||||
var _loc3_:Number = m_ground.m_xf.position.x + m_groundAnchor1.x;
|
||||
var _loc5_:Number = m_ground.m_xf.position.y + m_groundAnchor1.y;
|
||||
var _loc2_:Number = _loc1_.x - _loc3_;
|
||||
var _loc4_:Number = _loc1_.y - _loc5_;
|
||||
return Math.sqrt(_loc2_ * _loc2_ + _loc4_ * _loc4_);
|
||||
}
|
||||
|
||||
public function GetLength2() : Number
|
||||
{
|
||||
var _loc1_:b2Vec2 = m_body2.GetWorldPoint(m_localAnchor2);
|
||||
var _loc3_:Number = m_ground.m_xf.position.x + m_groundAnchor2.x;
|
||||
var _loc5_:Number = m_ground.m_xf.position.y + m_groundAnchor2.y;
|
||||
var _loc2_:Number = _loc1_.x - _loc3_;
|
||||
var _loc4_:Number = _loc1_.y - _loc5_;
|
||||
return Math.sqrt(_loc2_ * _loc2_ + _loc4_ * _loc4_);
|
||||
}
|
||||
|
||||
public function GetRatio() : Number
|
||||
{
|
||||
return m_ratio;
|
||||
}
|
||||
|
||||
override public function InitVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc22_:b2Mat22 = null;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc3_:b2Body = m_body1;
|
||||
var _loc4_:b2Body = m_body2;
|
||||
_loc22_ = _loc3_.m_xf.R;
|
||||
var _loc21_:Number = m_localAnchor1.x - _loc3_.m_sweep.localCenter.x;
|
||||
var _loc25_:Number = m_localAnchor1.y - _loc3_.m_sweep.localCenter.y;
|
||||
var _loc14_:Number = _loc22_.col1.x * _loc21_ + _loc22_.col2.x * _loc25_;
|
||||
_loc25_ = _loc22_.col1.y * _loc21_ + _loc22_.col2.y * _loc25_;
|
||||
_loc21_ = _loc14_;
|
||||
_loc22_ = _loc4_.m_xf.R;
|
||||
var _loc10_:Number = m_localAnchor2.x - _loc4_.m_sweep.localCenter.x;
|
||||
var _loc8_:Number = m_localAnchor2.y - _loc4_.m_sweep.localCenter.y;
|
||||
_loc14_ = _loc22_.col1.x * _loc10_ + _loc22_.col2.x * _loc8_;
|
||||
_loc8_ = _loc22_.col1.y * _loc10_ + _loc22_.col2.y * _loc8_;
|
||||
_loc10_ = _loc14_;
|
||||
var _loc18_:Number = _loc3_.m_sweep.c.x + _loc21_;
|
||||
var _loc23_:Number = _loc3_.m_sweep.c.y + _loc25_;
|
||||
var _loc7_:Number = _loc4_.m_sweep.c.x + _loc10_;
|
||||
var _loc5_:Number = _loc4_.m_sweep.c.y + _loc8_;
|
||||
var _loc26_:Number = m_ground.m_xf.position.x + m_groundAnchor1.x;
|
||||
var _loc24_:Number = m_ground.m_xf.position.y + m_groundAnchor1.y;
|
||||
var _loc9_:Number = m_ground.m_xf.position.x + m_groundAnchor2.x;
|
||||
var _loc13_:Number = m_ground.m_xf.position.y + m_groundAnchor2.y;
|
||||
m_u1.Set(_loc18_ - _loc26_,_loc23_ - _loc24_);
|
||||
m_u2.Set(_loc7_ - _loc9_,_loc5_ - _loc13_);
|
||||
var _loc16_:Number = m_u1.Length();
|
||||
var _loc17_:Number = m_u2.Length();
|
||||
if(_loc16_ > 0.005)
|
||||
{
|
||||
m_u1.Multiply(1 / _loc16_);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_u1.SetZero();
|
||||
}
|
||||
if(_loc17_ > 0.005)
|
||||
{
|
||||
m_u2.Multiply(1 / _loc17_);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_u2.SetZero();
|
||||
}
|
||||
var _loc2_:Number = m_constant - _loc16_ - m_ratio * _loc17_;
|
||||
if(_loc2_ > 0)
|
||||
{
|
||||
m_state = 0;
|
||||
m_force = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_state = 2;
|
||||
m_positionImpulse = 0;
|
||||
}
|
||||
if(_loc16_ < m_maxLength1)
|
||||
{
|
||||
m_limitState1 = 0;
|
||||
m_limitForce1 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_limitState1 = 2;
|
||||
m_limitPositionImpulse1 = 0;
|
||||
}
|
||||
if(_loc17_ < m_maxLength2)
|
||||
{
|
||||
m_limitState2 = 0;
|
||||
m_limitForce2 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_limitState2 = 2;
|
||||
m_limitPositionImpulse2 = 0;
|
||||
}
|
||||
var _loc11_:Number = _loc21_ * m_u1.y - _loc25_ * m_u1.x;
|
||||
var _loc15_:Number = _loc10_ * m_u2.y - _loc8_ * m_u2.x;
|
||||
m_limitMass1 = _loc3_.m_invMass + _loc3_.m_invI * _loc11_ * _loc11_;
|
||||
m_limitMass2 = _loc4_.m_invMass + _loc4_.m_invI * _loc15_ * _loc15_;
|
||||
m_pulleyMass = m_limitMass1 + m_ratio * m_ratio * m_limitMass2;
|
||||
m_limitMass1 = 1 / m_limitMass1;
|
||||
m_limitMass2 = 1 / m_limitMass2;
|
||||
m_pulleyMass = 1 / m_pulleyMass;
|
||||
if(param1.warmStarting)
|
||||
{
|
||||
_loc6_ = param1.dt * (-m_force - m_limitForce1) * m_u1.x;
|
||||
_loc12_ = param1.dt * (-m_force - m_limitForce1) * m_u1.y;
|
||||
_loc20_ = param1.dt * (-m_ratio * m_force - m_limitForce2) * m_u2.x;
|
||||
_loc19_ = param1.dt * (-m_ratio * m_force - m_limitForce2) * m_u2.y;
|
||||
_loc3_.m_linearVelocity.x += _loc3_.m_invMass * _loc6_;
|
||||
_loc3_.m_linearVelocity.y += _loc3_.m_invMass * _loc12_;
|
||||
_loc3_.m_angularVelocity += _loc3_.m_invI * (_loc21_ * _loc12_ - _loc25_ * _loc6_);
|
||||
_loc4_.m_linearVelocity.x += _loc4_.m_invMass * _loc20_;
|
||||
_loc4_.m_linearVelocity.y += _loc4_.m_invMass * _loc19_;
|
||||
_loc4_.m_angularVelocity += _loc4_.m_invI * (_loc10_ * _loc19_ - _loc8_ * _loc20_);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_force = 0;
|
||||
m_limitForce1 = 0;
|
||||
m_limitForce2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
override public function SolveVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc11_:b2Mat22 = null;
|
||||
var _loc17_:Number = NaN;
|
||||
var _loc20_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc5_:Number = NaN;
|
||||
var _loc3_:b2Body = m_body1;
|
||||
var _loc4_:b2Body = m_body2;
|
||||
_loc11_ = _loc3_.m_xf.R;
|
||||
var _loc9_:Number = m_localAnchor1.x - _loc3_.m_sweep.localCenter.x;
|
||||
var _loc16_:Number = m_localAnchor1.y - _loc3_.m_sweep.localCenter.y;
|
||||
var _loc2_:Number = _loc11_.col1.x * _loc9_ + _loc11_.col2.x * _loc16_;
|
||||
_loc16_ = _loc11_.col1.y * _loc9_ + _loc11_.col2.y * _loc16_;
|
||||
_loc9_ = _loc2_;
|
||||
_loc11_ = _loc4_.m_xf.R;
|
||||
var _loc12_:Number = m_localAnchor2.x - _loc4_.m_sweep.localCenter.x;
|
||||
var _loc10_:Number = m_localAnchor2.y - _loc4_.m_sweep.localCenter.y;
|
||||
_loc2_ = _loc11_.col1.x * _loc12_ + _loc11_.col2.x * _loc10_;
|
||||
_loc10_ = _loc11_.col1.y * _loc12_ + _loc11_.col2.y * _loc10_;
|
||||
_loc12_ = _loc2_;
|
||||
if(m_state == 2)
|
||||
{
|
||||
_loc17_ = _loc3_.m_linearVelocity.x + -_loc3_.m_angularVelocity * _loc16_;
|
||||
_loc20_ = _loc3_.m_linearVelocity.y + _loc3_.m_angularVelocity * _loc9_;
|
||||
_loc19_ = _loc4_.m_linearVelocity.x + -_loc4_.m_angularVelocity * _loc10_;
|
||||
_loc18_ = _loc4_.m_linearVelocity.y + _loc4_.m_angularVelocity * _loc12_;
|
||||
_loc14_ = -(m_u1.x * _loc17_ + m_u1.y * _loc20_) - m_ratio * (m_u2.x * _loc19_ + m_u2.y * _loc18_);
|
||||
_loc15_ = -param1.inv_dt * m_pulleyMass * _loc14_;
|
||||
_loc5_ = m_force;
|
||||
m_force = b2Math.b2Max(0,m_force + _loc15_);
|
||||
_loc15_ = m_force - _loc5_;
|
||||
_loc6_ = -param1.dt * _loc15_ * m_u1.x;
|
||||
_loc13_ = -param1.dt * _loc15_ * m_u1.y;
|
||||
_loc8_ = -param1.dt * m_ratio * _loc15_ * m_u2.x;
|
||||
_loc7_ = -param1.dt * m_ratio * _loc15_ * m_u2.y;
|
||||
_loc3_.m_linearVelocity.x += _loc3_.m_invMass * _loc6_;
|
||||
_loc3_.m_linearVelocity.y += _loc3_.m_invMass * _loc13_;
|
||||
_loc3_.m_angularVelocity += _loc3_.m_invI * (_loc9_ * _loc13_ - _loc16_ * _loc6_);
|
||||
_loc4_.m_linearVelocity.x += _loc4_.m_invMass * _loc8_;
|
||||
_loc4_.m_linearVelocity.y += _loc4_.m_invMass * _loc7_;
|
||||
_loc4_.m_angularVelocity += _loc4_.m_invI * (_loc12_ * _loc7_ - _loc10_ * _loc8_);
|
||||
}
|
||||
if(m_limitState1 == 2)
|
||||
{
|
||||
_loc17_ = _loc3_.m_linearVelocity.x + -_loc3_.m_angularVelocity * _loc16_;
|
||||
_loc20_ = _loc3_.m_linearVelocity.y + _loc3_.m_angularVelocity * _loc9_;
|
||||
_loc14_ = -(m_u1.x * _loc17_ + m_u1.y * _loc20_);
|
||||
_loc15_ = -param1.inv_dt * m_limitMass1 * _loc14_;
|
||||
_loc5_ = m_limitForce1;
|
||||
m_limitForce1 = b2Math.b2Max(0,m_limitForce1 + _loc15_);
|
||||
_loc15_ = m_limitForce1 - _loc5_;
|
||||
_loc6_ = -param1.dt * _loc15_ * m_u1.x;
|
||||
_loc13_ = -param1.dt * _loc15_ * m_u1.y;
|
||||
_loc3_.m_linearVelocity.x += _loc3_.m_invMass * _loc6_;
|
||||
_loc3_.m_linearVelocity.y += _loc3_.m_invMass * _loc13_;
|
||||
_loc3_.m_angularVelocity += _loc3_.m_invI * (_loc9_ * _loc13_ - _loc16_ * _loc6_);
|
||||
}
|
||||
if(m_limitState2 == 2)
|
||||
{
|
||||
_loc19_ = _loc4_.m_linearVelocity.x + -_loc4_.m_angularVelocity * _loc10_;
|
||||
_loc18_ = _loc4_.m_linearVelocity.y + _loc4_.m_angularVelocity * _loc12_;
|
||||
_loc14_ = -(m_u2.x * _loc19_ + m_u2.y * _loc18_);
|
||||
_loc15_ = -param1.inv_dt * m_limitMass2 * _loc14_;
|
||||
_loc5_ = m_limitForce2;
|
||||
m_limitForce2 = b2Math.b2Max(0,m_limitForce2 + _loc15_);
|
||||
_loc15_ = m_limitForce2 - _loc5_;
|
||||
_loc8_ = -param1.dt * _loc15_ * m_u2.x;
|
||||
_loc7_ = -param1.dt * _loc15_ * m_u2.y;
|
||||
_loc4_.m_linearVelocity.x += _loc4_.m_invMass * _loc8_;
|
||||
_loc4_.m_linearVelocity.y += _loc4_.m_invMass * _loc7_;
|
||||
_loc4_.m_angularVelocity += _loc4_.m_invI * (_loc12_ * _loc7_ - _loc10_ * _loc8_);
|
||||
}
|
||||
}
|
||||
|
||||
override public function SolvePositionConstraints() : Boolean
|
||||
{
|
||||
var _loc14_:b2Mat22 = null;
|
||||
var _loc12_:Number = NaN;
|
||||
var _loc22_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc8_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:Number = NaN;
|
||||
var _loc1_:Number = NaN;
|
||||
var _loc18_:Number = NaN;
|
||||
var _loc19_:Number = NaN;
|
||||
var _loc23_:Number = NaN;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc4_:b2Body = m_body1;
|
||||
var _loc5_:b2Body = m_body2;
|
||||
var _loc20_:Number = m_ground.m_xf.position.x + m_groundAnchor1.x;
|
||||
var _loc17_:Number = m_ground.m_xf.position.y + m_groundAnchor1.y;
|
||||
var _loc11_:Number = m_ground.m_xf.position.x + m_groundAnchor2.x;
|
||||
var _loc21_:Number = m_ground.m_xf.position.y + m_groundAnchor2.y;
|
||||
var _loc2_:Number = 0;
|
||||
if(m_state == 2)
|
||||
{
|
||||
_loc14_ = _loc4_.m_xf.R;
|
||||
_loc12_ = m_localAnchor1.x - _loc4_.m_sweep.localCenter.x;
|
||||
_loc22_ = m_localAnchor1.y - _loc4_.m_sweep.localCenter.y;
|
||||
_loc3_ = _loc14_.col1.x * _loc12_ + _loc14_.col2.x * _loc22_;
|
||||
_loc22_ = _loc14_.col1.y * _loc12_ + _loc14_.col2.y * _loc22_;
|
||||
_loc12_ = _loc3_;
|
||||
_loc14_ = _loc5_.m_xf.R;
|
||||
_loc15_ = m_localAnchor2.x - _loc5_.m_sweep.localCenter.x;
|
||||
_loc13_ = m_localAnchor2.y - _loc5_.m_sweep.localCenter.y;
|
||||
_loc3_ = _loc14_.col1.x * _loc15_ + _loc14_.col2.x * _loc13_;
|
||||
_loc13_ = _loc14_.col1.y * _loc15_ + _loc14_.col2.y * _loc13_;
|
||||
_loc15_ = _loc3_;
|
||||
_loc8_ = _loc4_.m_sweep.c.x + _loc12_;
|
||||
_loc16_ = _loc4_.m_sweep.c.y + _loc22_;
|
||||
_loc10_ = _loc5_.m_sweep.c.x + _loc15_;
|
||||
_loc9_ = _loc5_.m_sweep.c.y + _loc13_;
|
||||
m_u1.Set(_loc8_ - _loc20_,_loc16_ - _loc17_);
|
||||
m_u2.Set(_loc10_ - _loc11_,_loc9_ - _loc21_);
|
||||
_loc6_ = m_u1.Length();
|
||||
_loc7_ = m_u2.Length();
|
||||
if(_loc6_ > 0.005)
|
||||
{
|
||||
m_u1.Multiply(1 / _loc6_);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_u1.SetZero();
|
||||
}
|
||||
if(_loc7_ > 0.005)
|
||||
{
|
||||
m_u2.Multiply(1 / _loc7_);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_u2.SetZero();
|
||||
}
|
||||
_loc1_ = m_constant - _loc6_ - m_ratio * _loc7_;
|
||||
_loc2_ = b2Math.b2Max(_loc2_,-_loc1_);
|
||||
_loc1_ = b2Math.b2Clamp(_loc1_ + 0.005,-0.2,0);
|
||||
_loc18_ = -m_pulleyMass * _loc1_;
|
||||
_loc19_ = m_positionImpulse;
|
||||
m_positionImpulse = b2Math.b2Max(0,m_positionImpulse + _loc18_);
|
||||
_loc18_ = m_positionImpulse - _loc19_;
|
||||
_loc8_ = -_loc18_ * m_u1.x;
|
||||
_loc16_ = -_loc18_ * m_u1.y;
|
||||
_loc10_ = -m_ratio * _loc18_ * m_u2.x;
|
||||
_loc9_ = -m_ratio * _loc18_ * m_u2.y;
|
||||
_loc4_.m_sweep.c.x += _loc4_.m_invMass * _loc8_;
|
||||
_loc4_.m_sweep.c.y += _loc4_.m_invMass * _loc16_;
|
||||
_loc4_.m_sweep.a += _loc4_.m_invI * (_loc12_ * _loc16_ - _loc22_ * _loc8_);
|
||||
_loc5_.m_sweep.c.x += _loc5_.m_invMass * _loc10_;
|
||||
_loc5_.m_sweep.c.y += _loc5_.m_invMass * _loc9_;
|
||||
_loc5_.m_sweep.a += _loc5_.m_invI * (_loc15_ * _loc9_ - _loc13_ * _loc10_);
|
||||
_loc4_.SynchronizeTransform();
|
||||
_loc5_.SynchronizeTransform();
|
||||
}
|
||||
if(m_limitState1 == 2)
|
||||
{
|
||||
_loc14_ = _loc4_.m_xf.R;
|
||||
_loc12_ = m_localAnchor1.x - _loc4_.m_sweep.localCenter.x;
|
||||
_loc22_ = m_localAnchor1.y - _loc4_.m_sweep.localCenter.y;
|
||||
_loc3_ = _loc14_.col1.x * _loc12_ + _loc14_.col2.x * _loc22_;
|
||||
_loc22_ = _loc14_.col1.y * _loc12_ + _loc14_.col2.y * _loc22_;
|
||||
_loc12_ = _loc3_;
|
||||
_loc8_ = _loc4_.m_sweep.c.x + _loc12_;
|
||||
_loc16_ = _loc4_.m_sweep.c.y + _loc22_;
|
||||
m_u1.Set(_loc8_ - _loc20_,_loc16_ - _loc17_);
|
||||
_loc6_ = m_u1.Length();
|
||||
if(_loc6_ > 0.005)
|
||||
{
|
||||
m_u1.x *= 1 / _loc6_;
|
||||
m_u1.y *= 1 / _loc6_;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_u1.SetZero();
|
||||
}
|
||||
_loc1_ = m_maxLength1 - _loc6_;
|
||||
_loc2_ = b2Math.b2Max(_loc2_,-_loc1_);
|
||||
_loc1_ = b2Math.b2Clamp(_loc1_ + 0.005,-0.2,0);
|
||||
_loc18_ = -m_limitMass1 * _loc1_;
|
||||
_loc23_ = m_limitPositionImpulse1;
|
||||
m_limitPositionImpulse1 = b2Math.b2Max(0,m_limitPositionImpulse1 + _loc18_);
|
||||
_loc18_ = m_limitPositionImpulse1 - _loc23_;
|
||||
_loc8_ = -_loc18_ * m_u1.x;
|
||||
_loc16_ = -_loc18_ * m_u1.y;
|
||||
_loc4_.m_sweep.c.x += _loc4_.m_invMass * _loc8_;
|
||||
_loc4_.m_sweep.c.y += _loc4_.m_invMass * _loc16_;
|
||||
_loc4_.m_sweep.a += _loc4_.m_invI * (_loc12_ * _loc16_ - _loc22_ * _loc8_);
|
||||
_loc4_.SynchronizeTransform();
|
||||
}
|
||||
if(m_limitState2 == 2)
|
||||
{
|
||||
_loc14_ = _loc5_.m_xf.R;
|
||||
_loc15_ = m_localAnchor2.x - _loc5_.m_sweep.localCenter.x;
|
||||
_loc13_ = m_localAnchor2.y - _loc5_.m_sweep.localCenter.y;
|
||||
_loc3_ = _loc14_.col1.x * _loc15_ + _loc14_.col2.x * _loc13_;
|
||||
_loc13_ = _loc14_.col1.y * _loc15_ + _loc14_.col2.y * _loc13_;
|
||||
_loc15_ = _loc3_;
|
||||
_loc10_ = _loc5_.m_sweep.c.x + _loc15_;
|
||||
_loc9_ = _loc5_.m_sweep.c.y + _loc13_;
|
||||
m_u2.Set(_loc10_ - _loc11_,_loc9_ - _loc21_);
|
||||
_loc7_ = m_u2.Length();
|
||||
if(_loc7_ > 0.005)
|
||||
{
|
||||
m_u2.x *= 1 / _loc7_;
|
||||
m_u2.y *= 1 / _loc7_;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_u2.SetZero();
|
||||
}
|
||||
_loc1_ = m_maxLength2 - _loc7_;
|
||||
_loc2_ = b2Math.b2Max(_loc2_,-_loc1_);
|
||||
_loc1_ = b2Math.b2Clamp(_loc1_ + 0.005,-0.2,0);
|
||||
_loc18_ = -m_limitMass2 * _loc1_;
|
||||
_loc23_ = m_limitPositionImpulse2;
|
||||
m_limitPositionImpulse2 = b2Math.b2Max(0,m_limitPositionImpulse2 + _loc18_);
|
||||
_loc18_ = m_limitPositionImpulse2 - _loc23_;
|
||||
_loc10_ = -_loc18_ * m_u2.x;
|
||||
_loc9_ = -_loc18_ * m_u2.y;
|
||||
_loc5_.m_sweep.c.x += _loc5_.m_invMass * _loc10_;
|
||||
_loc5_.m_sweep.c.y += _loc5_.m_invMass * _loc9_;
|
||||
_loc5_.m_sweep.a += _loc5_.m_invI * (_loc15_ * _loc9_ - _loc13_ * _loc10_);
|
||||
_loc5_.SynchronizeTransform();
|
||||
}
|
||||
return _loc2_ < 0.005;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
|
||||
public class b2PulleyJointDef extends b2JointDef
|
||||
{
|
||||
|
||||
public var groundAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var groundAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var length1:Number;
|
||||
|
||||
public var maxLength1:Number;
|
||||
|
||||
public var length2:Number;
|
||||
|
||||
public var maxLength2:Number;
|
||||
|
||||
public var ratio:Number;
|
||||
|
||||
public function b2PulleyJointDef()
|
||||
{
|
||||
super();
|
||||
type = 4;
|
||||
groundAnchor1.Set(-1,1);
|
||||
groundAnchor2.Set(1,1);
|
||||
localAnchor1.Set(-1,0);
|
||||
localAnchor2.Set(1,0);
|
||||
length1 = 0;
|
||||
maxLength1 = 0;
|
||||
length2 = 0;
|
||||
maxLength2 = 0;
|
||||
ratio = 1;
|
||||
collideConnected = true;
|
||||
}
|
||||
|
||||
public function Initialize(param1:b2Body, param2:b2Body, param3:b2Vec2, param4:b2Vec2, param5:b2Vec2, param6:b2Vec2, param7:Number) : void
|
||||
{
|
||||
body1 = param1;
|
||||
body2 = param2;
|
||||
groundAnchor1.SetV(param3);
|
||||
groundAnchor2.SetV(param4);
|
||||
localAnchor1 = body1.GetLocalPoint(param5);
|
||||
localAnchor2 = body2.GetLocalPoint(param6);
|
||||
var _loc9_:Number = param5.x - param3.x;
|
||||
var _loc12_:Number = param5.y - param3.y;
|
||||
length1 = Math.sqrt(_loc9_ * _loc9_ + _loc12_ * _loc12_);
|
||||
var _loc11_:Number = param6.x - param4.x;
|
||||
var _loc10_:Number = param6.y - param4.y;
|
||||
length2 = Math.sqrt(_loc11_ * _loc11_ + _loc10_ * _loc10_);
|
||||
ratio = param7;
|
||||
var _loc8_:Number = length1 + ratio * length2;
|
||||
maxLength1 = _loc8_ - ratio * 2;
|
||||
maxLength2 = (_loc8_ - 2) / ratio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,425 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Mat22;
|
||||
import Box2D.Common.Math.b2Math;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
import Box2D.Dynamics.b2TimeStep;
|
||||
|
||||
public class b2RevoluteJoint extends b2Joint
|
||||
{
|
||||
|
||||
public static var tImpulse:b2Vec2 = new b2Vec2();
|
||||
|
||||
private var K:b2Mat22 = new b2Mat22();
|
||||
|
||||
private var K1:b2Mat22 = new b2Mat22();
|
||||
|
||||
private var K2:b2Mat22 = new b2Mat22();
|
||||
|
||||
private var K3:b2Mat22 = new b2Mat22();
|
||||
|
||||
public var m_localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_pivotForce:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_motorForce:Number;
|
||||
|
||||
public var m_limitForce:Number;
|
||||
|
||||
public var m_limitPositionImpulse:Number;
|
||||
|
||||
public var m_pivotMass:b2Mat22 = new b2Mat22();
|
||||
|
||||
public var m_motorMass:Number;
|
||||
|
||||
public var m_enableMotor:Boolean;
|
||||
|
||||
public var m_maxMotorTorque:Number;
|
||||
|
||||
public var m_motorSpeed:Number;
|
||||
|
||||
public var m_enableLimit:Boolean;
|
||||
|
||||
public var m_referenceAngle:Number;
|
||||
|
||||
public var m_lowerAngle:Number;
|
||||
|
||||
public var m_upperAngle:Number;
|
||||
|
||||
public var m_limitState:int;
|
||||
|
||||
public function b2RevoluteJoint(param1:b2RevoluteJointDef)
|
||||
{
|
||||
super(param1);
|
||||
m_localAnchor1.SetV(param1.localAnchor1);
|
||||
m_localAnchor2.SetV(param1.localAnchor2);
|
||||
m_referenceAngle = param1.referenceAngle;
|
||||
m_pivotForce.Set(0,0);
|
||||
m_motorForce = 0;
|
||||
m_limitForce = 0;
|
||||
m_limitPositionImpulse = 0;
|
||||
m_lowerAngle = param1.lowerAngle;
|
||||
m_upperAngle = param1.upperAngle;
|
||||
m_maxMotorTorque = param1.maxMotorTorque;
|
||||
m_motorSpeed = param1.motorSpeed;
|
||||
m_enableLimit = param1.enableLimit;
|
||||
m_enableMotor = param1.enableMotor;
|
||||
}
|
||||
|
||||
override public function GetAnchor1() : b2Vec2
|
||||
{
|
||||
return m_body1.GetWorldPoint(m_localAnchor1);
|
||||
}
|
||||
|
||||
override public function GetAnchor2() : b2Vec2
|
||||
{
|
||||
return m_body2.GetWorldPoint(m_localAnchor2);
|
||||
}
|
||||
|
||||
override public function GetReactionForce() : b2Vec2
|
||||
{
|
||||
return m_pivotForce;
|
||||
}
|
||||
|
||||
override public function GetReactionTorque() : Number
|
||||
{
|
||||
return m_limitForce;
|
||||
}
|
||||
|
||||
public function GetJointAngle() : Number
|
||||
{
|
||||
return m_body2.m_sweep.a - m_body1.m_sweep.a - m_referenceAngle;
|
||||
}
|
||||
|
||||
public function GetJointSpeed() : Number
|
||||
{
|
||||
return m_body2.m_angularVelocity - m_body1.m_angularVelocity;
|
||||
}
|
||||
|
||||
public function IsLimitEnabled() : Boolean
|
||||
{
|
||||
return m_enableLimit;
|
||||
}
|
||||
|
||||
public function EnableLimit(param1:Boolean) : void
|
||||
{
|
||||
m_enableLimit = param1;
|
||||
}
|
||||
|
||||
public function GetLowerLimit() : Number
|
||||
{
|
||||
return m_lowerAngle;
|
||||
}
|
||||
|
||||
public function GetUpperLimit() : Number
|
||||
{
|
||||
return m_upperAngle;
|
||||
}
|
||||
|
||||
public function SetLimits(param1:Number, param2:Number) : void
|
||||
{
|
||||
m_lowerAngle = param1;
|
||||
m_upperAngle = param2;
|
||||
}
|
||||
|
||||
public function IsMotorEnabled() : Boolean
|
||||
{
|
||||
return m_enableMotor;
|
||||
}
|
||||
|
||||
public function EnableMotor(param1:Boolean) : void
|
||||
{
|
||||
m_enableMotor = param1;
|
||||
}
|
||||
|
||||
public function SetMotorSpeed(param1:Number) : void
|
||||
{
|
||||
m_motorSpeed = param1;
|
||||
}
|
||||
|
||||
public function GetMotorSpeed() : Number
|
||||
{
|
||||
return m_motorSpeed;
|
||||
}
|
||||
|
||||
public function SetMaxMotorTorque(param1:Number) : void
|
||||
{
|
||||
m_maxMotorTorque = param1;
|
||||
}
|
||||
|
||||
public function GetMotorTorque() : Number
|
||||
{
|
||||
return m_motorForce;
|
||||
}
|
||||
|
||||
override public function InitVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc11_:b2Mat22 = null;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc14_:Number = NaN;
|
||||
var _loc7_:b2Body = m_body1;
|
||||
var _loc8_:b2Body = m_body2;
|
||||
_loc11_ = _loc7_.m_xf.R;
|
||||
var _loc9_:Number = m_localAnchor1.x - _loc7_.m_sweep.localCenter.x;
|
||||
var _loc13_:Number = m_localAnchor1.y - _loc7_.m_sweep.localCenter.y;
|
||||
_loc6_ = _loc11_.col1.x * _loc9_ + _loc11_.col2.x * _loc13_;
|
||||
_loc13_ = _loc11_.col1.y * _loc9_ + _loc11_.col2.y * _loc13_;
|
||||
_loc9_ = _loc6_;
|
||||
_loc11_ = _loc8_.m_xf.R;
|
||||
var _loc12_:Number = m_localAnchor2.x - _loc8_.m_sweep.localCenter.x;
|
||||
var _loc10_:Number = m_localAnchor2.y - _loc8_.m_sweep.localCenter.y;
|
||||
_loc6_ = _loc11_.col1.x * _loc12_ + _loc11_.col2.x * _loc10_;
|
||||
_loc10_ = _loc11_.col1.y * _loc12_ + _loc11_.col2.y * _loc10_;
|
||||
_loc12_ = _loc6_;
|
||||
var _loc5_:Number = _loc7_.m_invMass;
|
||||
var _loc3_:Number = _loc8_.m_invMass;
|
||||
var _loc4_:Number = _loc7_.m_invI;
|
||||
var _loc2_:Number = _loc8_.m_invI;
|
||||
K1.col1.x = _loc5_ + _loc3_;
|
||||
K1.col2.x = 0;
|
||||
K1.col1.y = 0;
|
||||
K1.col2.y = _loc5_ + _loc3_;
|
||||
K2.col1.x = _loc4_ * _loc13_ * _loc13_;
|
||||
K2.col2.x = -_loc4_ * _loc9_ * _loc13_;
|
||||
K2.col1.y = -_loc4_ * _loc9_ * _loc13_;
|
||||
K2.col2.y = _loc4_ * _loc9_ * _loc9_;
|
||||
K3.col1.x = _loc2_ * _loc10_ * _loc10_;
|
||||
K3.col2.x = -_loc2_ * _loc12_ * _loc10_;
|
||||
K3.col1.y = -_loc2_ * _loc12_ * _loc10_;
|
||||
K3.col2.y = _loc2_ * _loc12_ * _loc12_;
|
||||
K.SetM(K1);
|
||||
K.AddM(K2);
|
||||
K.AddM(K3);
|
||||
K.Invert(m_pivotMass);
|
||||
m_motorMass = 1 / (_loc4_ + _loc2_);
|
||||
if(m_enableMotor == false)
|
||||
{
|
||||
m_motorForce = 0;
|
||||
}
|
||||
if(m_enableLimit)
|
||||
{
|
||||
_loc14_ = _loc8_.m_sweep.a - _loc7_.m_sweep.a - m_referenceAngle;
|
||||
if(b2Math.b2Abs(m_upperAngle - m_lowerAngle) < 2 * 0.03490658503988659)
|
||||
{
|
||||
m_limitState = 3;
|
||||
}
|
||||
else if(_loc14_ <= m_lowerAngle)
|
||||
{
|
||||
if(m_limitState != 1)
|
||||
{
|
||||
m_limitForce = 0;
|
||||
}
|
||||
m_limitState = 1;
|
||||
}
|
||||
else if(_loc14_ >= m_upperAngle)
|
||||
{
|
||||
if(m_limitState != 2)
|
||||
{
|
||||
m_limitForce = 0;
|
||||
}
|
||||
m_limitState = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_limitState = 0;
|
||||
m_limitForce = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_limitForce = 0;
|
||||
}
|
||||
if(param1.warmStarting)
|
||||
{
|
||||
_loc7_.m_linearVelocity.x -= param1.dt * _loc5_ * m_pivotForce.x;
|
||||
_loc7_.m_linearVelocity.y -= param1.dt * _loc5_ * m_pivotForce.y;
|
||||
_loc7_.m_angularVelocity -= param1.dt * _loc4_ * (_loc9_ * m_pivotForce.y - _loc13_ * m_pivotForce.x + m_motorForce + m_limitForce);
|
||||
_loc8_.m_linearVelocity.x += param1.dt * _loc3_ * m_pivotForce.x;
|
||||
_loc8_.m_linearVelocity.y += param1.dt * _loc3_ * m_pivotForce.y;
|
||||
_loc8_.m_angularVelocity += param1.dt * _loc2_ * (_loc12_ * m_pivotForce.y - _loc10_ * m_pivotForce.x + m_motorForce + m_limitForce);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pivotForce.SetZero();
|
||||
m_motorForce = 0;
|
||||
m_limitForce = 0;
|
||||
}
|
||||
m_limitPositionImpulse = 0;
|
||||
}
|
||||
|
||||
override public function SolveVelocityConstraints(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc18_:b2Mat22 = null;
|
||||
var _loc3_:Number = NaN;
|
||||
var _loc11_:Number = NaN;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc6_:Number = NaN;
|
||||
var _loc7_:b2Body = m_body1;
|
||||
var _loc8_:b2Body = m_body2;
|
||||
_loc18_ = _loc7_.m_xf.R;
|
||||
var _loc16_:Number = m_localAnchor1.x - _loc7_.m_sweep.localCenter.x;
|
||||
var _loc20_:Number = m_localAnchor1.y - _loc7_.m_sweep.localCenter.y;
|
||||
_loc3_ = _loc18_.col1.x * _loc16_ + _loc18_.col2.x * _loc20_;
|
||||
_loc20_ = _loc18_.col1.y * _loc16_ + _loc18_.col2.y * _loc20_;
|
||||
_loc16_ = _loc3_;
|
||||
_loc18_ = _loc8_.m_xf.R;
|
||||
var _loc19_:Number = m_localAnchor2.x - _loc8_.m_sweep.localCenter.x;
|
||||
var _loc17_:Number = m_localAnchor2.y - _loc8_.m_sweep.localCenter.y;
|
||||
_loc3_ = _loc18_.col1.x * _loc19_ + _loc18_.col2.x * _loc17_;
|
||||
_loc17_ = _loc18_.col1.y * _loc19_ + _loc18_.col2.y * _loc17_;
|
||||
_loc19_ = _loc3_;
|
||||
var _loc12_:Number = _loc8_.m_linearVelocity.x + -_loc8_.m_angularVelocity * _loc17_ - _loc7_.m_linearVelocity.x - -_loc7_.m_angularVelocity * _loc20_;
|
||||
var _loc14_:Number = _loc8_.m_linearVelocity.y + _loc8_.m_angularVelocity * _loc19_ - _loc7_.m_linearVelocity.y - _loc7_.m_angularVelocity * _loc16_;
|
||||
var _loc21_:Number = -param1.inv_dt * (m_pivotMass.col1.x * _loc12_ + m_pivotMass.col2.x * _loc14_);
|
||||
var _loc2_:Number = -param1.inv_dt * (m_pivotMass.col1.y * _loc12_ + m_pivotMass.col2.y * _loc14_);
|
||||
m_pivotForce.x += _loc21_;
|
||||
m_pivotForce.y += _loc2_;
|
||||
var _loc4_:Number = param1.dt * _loc21_;
|
||||
var _loc5_:Number = param1.dt * _loc2_;
|
||||
_loc7_.m_linearVelocity.x -= _loc7_.m_invMass * _loc4_;
|
||||
_loc7_.m_linearVelocity.y -= _loc7_.m_invMass * _loc5_;
|
||||
_loc7_.m_angularVelocity -= _loc7_.m_invI * (_loc16_ * _loc5_ - _loc20_ * _loc4_);
|
||||
_loc8_.m_linearVelocity.x += _loc8_.m_invMass * _loc4_;
|
||||
_loc8_.m_linearVelocity.y += _loc8_.m_invMass * _loc5_;
|
||||
_loc8_.m_angularVelocity += _loc8_.m_invI * (_loc19_ * _loc5_ - _loc17_ * _loc4_);
|
||||
if(m_enableMotor && m_limitState != 3)
|
||||
{
|
||||
_loc15_ = _loc8_.m_angularVelocity - _loc7_.m_angularVelocity - m_motorSpeed;
|
||||
_loc13_ = -param1.inv_dt * m_motorMass * _loc15_;
|
||||
_loc9_ = m_motorForce;
|
||||
m_motorForce = b2Math.b2Clamp(m_motorForce + _loc13_,-m_maxMotorTorque,m_maxMotorTorque);
|
||||
_loc13_ = m_motorForce - _loc9_;
|
||||
_loc7_.m_angularVelocity -= _loc7_.m_invI * param1.dt * _loc13_;
|
||||
_loc8_.m_angularVelocity += _loc8_.m_invI * param1.dt * _loc13_;
|
||||
}
|
||||
if(m_enableLimit && m_limitState != 0)
|
||||
{
|
||||
_loc10_ = _loc8_.m_angularVelocity - _loc7_.m_angularVelocity;
|
||||
_loc6_ = -param1.inv_dt * m_motorMass * _loc10_;
|
||||
if(m_limitState == 3)
|
||||
{
|
||||
m_limitForce += _loc6_;
|
||||
}
|
||||
else if(m_limitState == 1)
|
||||
{
|
||||
_loc11_ = m_limitForce;
|
||||
m_limitForce = b2Math.b2Max(m_limitForce + _loc6_,0);
|
||||
_loc6_ = m_limitForce - _loc11_;
|
||||
}
|
||||
else if(m_limitState == 2)
|
||||
{
|
||||
_loc11_ = m_limitForce;
|
||||
m_limitForce = b2Math.b2Min(m_limitForce + _loc6_,0);
|
||||
_loc6_ = m_limitForce - _loc11_;
|
||||
}
|
||||
_loc7_.m_angularVelocity -= _loc7_.m_invI * param1.dt * _loc6_;
|
||||
_loc8_.m_angularVelocity += _loc8_.m_invI * param1.dt * _loc6_;
|
||||
}
|
||||
}
|
||||
|
||||
override public function SolvePositionConstraints() : Boolean
|
||||
{
|
||||
var _loc10_:Number = NaN;
|
||||
var _loc21_:Number = NaN;
|
||||
var _loc24_:b2Mat22 = null;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc16_:Number = NaN;
|
||||
var _loc8_:b2Body = m_body1;
|
||||
var _loc9_:b2Body = m_body2;
|
||||
var _loc3_:Number = 0;
|
||||
_loc24_ = _loc8_.m_xf.R;
|
||||
var _loc23_:Number = m_localAnchor1.x - _loc8_.m_sweep.localCenter.x;
|
||||
var _loc26_:Number = m_localAnchor1.y - _loc8_.m_sweep.localCenter.y;
|
||||
var _loc18_:Number = _loc24_.col1.x * _loc23_ + _loc24_.col2.x * _loc26_;
|
||||
_loc26_ = _loc24_.col1.y * _loc23_ + _loc24_.col2.y * _loc26_;
|
||||
_loc23_ = _loc18_;
|
||||
_loc24_ = _loc9_.m_xf.R;
|
||||
var _loc14_:Number = m_localAnchor2.x - _loc9_.m_sweep.localCenter.x;
|
||||
var _loc13_:Number = m_localAnchor2.y - _loc9_.m_sweep.localCenter.y;
|
||||
_loc18_ = _loc24_.col1.x * _loc14_ + _loc24_.col2.x * _loc13_;
|
||||
_loc13_ = _loc24_.col1.y * _loc14_ + _loc24_.col2.y * _loc13_;
|
||||
_loc14_ = _loc18_;
|
||||
var _loc22_:Number = _loc8_.m_sweep.c.x + _loc23_;
|
||||
var _loc25_:Number = _loc8_.m_sweep.c.y + _loc26_;
|
||||
var _loc12_:Number = _loc9_.m_sweep.c.x + _loc14_;
|
||||
var _loc11_:Number = _loc9_.m_sweep.c.y + _loc13_;
|
||||
var _loc1_:Number = _loc12_ - _loc22_;
|
||||
var _loc4_:Number = _loc11_ - _loc25_;
|
||||
_loc3_ = Math.sqrt(_loc1_ * _loc1_ + _loc4_ * _loc4_);
|
||||
var _loc7_:Number = _loc8_.m_invMass;
|
||||
var _loc5_:Number = _loc9_.m_invMass;
|
||||
var _loc6_:Number = _loc8_.m_invI;
|
||||
var _loc2_:Number = _loc9_.m_invI;
|
||||
K1.col1.x = _loc7_ + _loc5_;
|
||||
K1.col2.x = 0;
|
||||
K1.col1.y = 0;
|
||||
K1.col2.y = _loc7_ + _loc5_;
|
||||
K2.col1.x = _loc6_ * _loc26_ * _loc26_;
|
||||
K2.col2.x = -_loc6_ * _loc23_ * _loc26_;
|
||||
K2.col1.y = -_loc6_ * _loc23_ * _loc26_;
|
||||
K2.col2.y = _loc6_ * _loc23_ * _loc23_;
|
||||
K3.col1.x = _loc2_ * _loc13_ * _loc13_;
|
||||
K3.col2.x = -_loc2_ * _loc14_ * _loc13_;
|
||||
K3.col1.y = -_loc2_ * _loc14_ * _loc13_;
|
||||
K3.col2.y = _loc2_ * _loc14_ * _loc14_;
|
||||
K.SetM(K1);
|
||||
K.AddM(K2);
|
||||
K.AddM(K3);
|
||||
K.Solve(tImpulse,-_loc1_,-_loc4_);
|
||||
var _loc19_:Number = tImpulse.x;
|
||||
var _loc17_:Number = tImpulse.y;
|
||||
_loc8_.m_sweep.c.x -= _loc8_.m_invMass * _loc19_;
|
||||
_loc8_.m_sweep.c.y -= _loc8_.m_invMass * _loc17_;
|
||||
_loc8_.m_sweep.a -= _loc8_.m_invI * (_loc23_ * _loc17_ - _loc26_ * _loc19_);
|
||||
_loc9_.m_sweep.c.x += _loc9_.m_invMass * _loc19_;
|
||||
_loc9_.m_sweep.c.y += _loc9_.m_invMass * _loc17_;
|
||||
_loc9_.m_sweep.a += _loc9_.m_invI * (_loc14_ * _loc17_ - _loc13_ * _loc19_);
|
||||
_loc8_.SynchronizeTransform();
|
||||
_loc9_.SynchronizeTransform();
|
||||
var _loc20_:Number = 0;
|
||||
if(m_enableLimit && m_limitState != 0)
|
||||
{
|
||||
_loc15_ = _loc9_.m_sweep.a - _loc8_.m_sweep.a - m_referenceAngle;
|
||||
_loc16_ = 0;
|
||||
if(m_limitState == 3)
|
||||
{
|
||||
_loc21_ = b2Math.b2Clamp(_loc15_,-0.13962634015954636,0.13962634015954636);
|
||||
_loc16_ = -m_motorMass * _loc21_;
|
||||
_loc20_ = b2Math.b2Abs(_loc21_);
|
||||
}
|
||||
else if(m_limitState == 1)
|
||||
{
|
||||
_loc21_ = _loc15_ - m_lowerAngle;
|
||||
_loc20_ = b2Math.b2Max(0,-_loc21_);
|
||||
_loc21_ = b2Math.b2Clamp(_loc21_ + 0.03490658503988659,-0.13962634015954636,0);
|
||||
_loc16_ = -m_motorMass * _loc21_;
|
||||
_loc10_ = m_limitPositionImpulse;
|
||||
m_limitPositionImpulse = b2Math.b2Max(m_limitPositionImpulse + _loc16_,0);
|
||||
_loc16_ = m_limitPositionImpulse - _loc10_;
|
||||
}
|
||||
else if(m_limitState == 2)
|
||||
{
|
||||
_loc21_ = _loc15_ - m_upperAngle;
|
||||
_loc20_ = b2Math.b2Max(0,_loc21_);
|
||||
_loc21_ = b2Math.b2Clamp(_loc21_ - 0.03490658503988659,0,0.13962634015954636);
|
||||
_loc16_ = -m_motorMass * _loc21_;
|
||||
_loc10_ = m_limitPositionImpulse;
|
||||
m_limitPositionImpulse = b2Math.b2Min(m_limitPositionImpulse + _loc16_,0);
|
||||
_loc16_ = m_limitPositionImpulse - _loc10_;
|
||||
}
|
||||
_loc8_.m_sweep.a -= _loc8_.m_invI * _loc16_;
|
||||
_loc9_.m_sweep.a += _loc9_.m_invI * _loc16_;
|
||||
_loc8_.SynchronizeTransform();
|
||||
_loc9_.SynchronizeTransform();
|
||||
}
|
||||
return _loc3_ <= 0.005 && _loc20_ <= 0.03490658503988659;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package Box2D.Dynamics.Joints
|
||||
{
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Dynamics.b2Body;
|
||||
|
||||
public class b2RevoluteJointDef extends b2JointDef
|
||||
{
|
||||
|
||||
public var localAnchor1:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var localAnchor2:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var referenceAngle:Number;
|
||||
|
||||
public var enableLimit:Boolean;
|
||||
|
||||
public var lowerAngle:Number;
|
||||
|
||||
public var upperAngle:Number;
|
||||
|
||||
public var enableMotor:Boolean;
|
||||
|
||||
public var motorSpeed:Number;
|
||||
|
||||
public var maxMotorTorque:Number;
|
||||
|
||||
public function b2RevoluteJointDef()
|
||||
{
|
||||
super();
|
||||
type = 1;
|
||||
localAnchor1.Set(0,0);
|
||||
localAnchor2.Set(0,0);
|
||||
referenceAngle = 0;
|
||||
lowerAngle = 0;
|
||||
upperAngle = 0;
|
||||
maxMotorTorque = 0;
|
||||
motorSpeed = 0;
|
||||
enableLimit = false;
|
||||
enableMotor = false;
|
||||
}
|
||||
|
||||
public function Initialize(param1:b2Body, param2:b2Body, param3:b2Vec2) : void
|
||||
{
|
||||
body1 = param1;
|
||||
body2 = param2;
|
||||
localAnchor1 = body1.GetLocalPoint(param3);
|
||||
localAnchor2 = body2.GetLocalPoint(param3);
|
||||
referenceAngle = body2.GetAngle() - body1.GetAngle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,679 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2MassData;
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Collision.Shapes.b2ShapeDef;
|
||||
import Box2D.Common.Math.b2Mat22;
|
||||
import Box2D.Common.Math.b2Math;
|
||||
import Box2D.Common.Math.b2Sweep;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
import Box2D.Common.Math.b2XForm;
|
||||
import Box2D.Dynamics.Contacts.b2ContactEdge;
|
||||
import Box2D.Dynamics.Joints.b2JointEdge;
|
||||
|
||||
public class b2Body
|
||||
{
|
||||
|
||||
public static var e_frozenFlag:uint = 2;
|
||||
|
||||
public static var e_islandFlag:uint = 4;
|
||||
|
||||
public static var e_sleepFlag:uint = 8;
|
||||
|
||||
public static var e_allowSleepFlag:uint = 16;
|
||||
|
||||
public static var e_bulletFlag:uint = 32;
|
||||
|
||||
public static var e_fixedRotationFlag:uint = 64;
|
||||
|
||||
public static var e_staticType:uint = 1;
|
||||
|
||||
public static var e_dynamicType:uint = 2;
|
||||
|
||||
public static var e_maxTypes:uint = 3;
|
||||
|
||||
private static var s_massData:b2MassData = new b2MassData();
|
||||
|
||||
private static var s_xf1:b2XForm = new b2XForm();
|
||||
|
||||
public var m_flags:uint;
|
||||
|
||||
public var m_type:int;
|
||||
|
||||
public var m_xf:b2XForm = new b2XForm();
|
||||
|
||||
public var m_sweep:b2Sweep = new b2Sweep();
|
||||
|
||||
public var m_linearVelocity:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_angularVelocity:Number;
|
||||
|
||||
public var m_force:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var m_torque:Number;
|
||||
|
||||
public var m_world:b2World;
|
||||
|
||||
public var m_prev:b2Body;
|
||||
|
||||
public var m_next:b2Body;
|
||||
|
||||
public var m_shapeList:b2Shape;
|
||||
|
||||
public var m_shapeCount:int;
|
||||
|
||||
public var m_jointList:b2JointEdge;
|
||||
|
||||
public var m_contactList:b2ContactEdge;
|
||||
|
||||
public var m_mass:Number;
|
||||
|
||||
public var m_invMass:Number;
|
||||
|
||||
public var m_I:Number;
|
||||
|
||||
public var m_invI:Number;
|
||||
|
||||
public var m_linearDamping:Number;
|
||||
|
||||
public var m_angularDamping:Number;
|
||||
|
||||
public var m_sleepTime:Number;
|
||||
|
||||
public var m_userData:*;
|
||||
|
||||
public function b2Body(param1:b2BodyDef, param2:b2World)
|
||||
{
|
||||
super();
|
||||
m_flags = 0;
|
||||
if(param1.isBullet)
|
||||
{
|
||||
m_flags |= e_bulletFlag;
|
||||
}
|
||||
if(param1.fixedRotation)
|
||||
{
|
||||
m_flags |= e_fixedRotationFlag;
|
||||
}
|
||||
if(param1.allowSleep)
|
||||
{
|
||||
m_flags |= e_allowSleepFlag;
|
||||
}
|
||||
if(param1.isSleeping)
|
||||
{
|
||||
m_flags |= e_sleepFlag;
|
||||
}
|
||||
m_world = param2;
|
||||
m_xf.position.SetV(param1.position);
|
||||
m_xf.R.Set(param1.angle);
|
||||
m_sweep.localCenter.SetV(param1.massData.center);
|
||||
m_sweep.t0 = 1;
|
||||
m_sweep.a0 = m_sweep.a = param1.angle;
|
||||
var _loc4_:b2Mat22 = m_xf.R;
|
||||
var _loc3_:b2Vec2 = m_sweep.localCenter;
|
||||
m_sweep.c.x = _loc4_.col1.x * _loc3_.x + _loc4_.col2.x * _loc3_.y;
|
||||
m_sweep.c.y = _loc4_.col1.y * _loc3_.x + _loc4_.col2.y * _loc3_.y;
|
||||
m_sweep.c.x += m_xf.position.x;
|
||||
m_sweep.c.y += m_xf.position.y;
|
||||
m_sweep.c0.SetV(m_sweep.c);
|
||||
m_jointList = null;
|
||||
m_contactList = null;
|
||||
m_prev = null;
|
||||
m_next = null;
|
||||
m_linearDamping = param1.linearDamping;
|
||||
m_angularDamping = param1.angularDamping;
|
||||
m_force.Set(0,0);
|
||||
m_torque = 0;
|
||||
m_linearVelocity.SetZero();
|
||||
m_angularVelocity = 0;
|
||||
m_sleepTime = 0;
|
||||
m_invMass = 0;
|
||||
m_I = 0;
|
||||
m_invI = 0;
|
||||
m_mass = param1.massData.mass;
|
||||
if(m_mass > 0)
|
||||
{
|
||||
m_invMass = 1 / m_mass;
|
||||
}
|
||||
if((m_flags & b2Body.e_fixedRotationFlag) == 0)
|
||||
{
|
||||
m_I = param1.massData.I;
|
||||
}
|
||||
if(m_I > 0)
|
||||
{
|
||||
m_invI = 1 / m_I;
|
||||
}
|
||||
if(m_invMass == 0 && m_invI == 0)
|
||||
{
|
||||
m_type = e_staticType;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_type = e_dynamicType;
|
||||
}
|
||||
m_userData = param1.userData;
|
||||
m_shapeList = null;
|
||||
m_shapeCount = 0;
|
||||
}
|
||||
|
||||
public function CreateShape(param1:b2ShapeDef) : b2Shape
|
||||
{
|
||||
if(m_world.m_lock == true)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var _loc2_:b2Shape = b2Shape.Create(param1,m_world.m_blockAllocator);
|
||||
_loc2_.m_next = m_shapeList;
|
||||
m_shapeList = _loc2_;
|
||||
m_shapeCount = m_shapeCount + 1;
|
||||
_loc2_.m_body = this;
|
||||
_loc2_.CreateProxy(m_world.m_broadPhase,m_xf);
|
||||
_loc2_.UpdateSweepRadius(m_sweep.localCenter);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function DestroyShape(param1:b2Shape) : void
|
||||
{
|
||||
if(m_world.m_lock == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
param1.DestroyProxy(m_world.m_broadPhase);
|
||||
var _loc2_:b2Shape = m_shapeList;
|
||||
var _loc3_:b2Shape = null;
|
||||
var _loc4_:Boolean = false;
|
||||
while(_loc2_ != null)
|
||||
{
|
||||
if(_loc2_ == param1)
|
||||
{
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc3_.m_next = param1.m_next;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_shapeList = param1.m_next;
|
||||
}
|
||||
_loc4_ = true;
|
||||
break;
|
||||
}
|
||||
_loc3_ = _loc2_;
|
||||
_loc2_ = _loc2_.m_next;
|
||||
}
|
||||
param1.m_body = null;
|
||||
param1.m_next = null;
|
||||
m_shapeCount = m_shapeCount - 1;
|
||||
b2Shape.Destroy(param1,m_world.m_blockAllocator);
|
||||
}
|
||||
|
||||
public function SetMass(param1:b2MassData) : void
|
||||
{
|
||||
var _loc2_:b2Shape = null;
|
||||
if(m_world.m_lock == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_invMass = 0;
|
||||
m_I = 0;
|
||||
m_invI = 0;
|
||||
m_mass = param1.mass;
|
||||
if(m_mass > 0)
|
||||
{
|
||||
m_invMass = 1 / m_mass;
|
||||
}
|
||||
if((m_flags & b2Body.e_fixedRotationFlag) == 0)
|
||||
{
|
||||
m_I = param1.I;
|
||||
}
|
||||
if(m_I > 0)
|
||||
{
|
||||
m_invI = 1 / m_I;
|
||||
}
|
||||
m_sweep.localCenter.SetV(param1.center);
|
||||
var _loc4_:b2Mat22 = m_xf.R;
|
||||
var _loc3_:b2Vec2 = m_sweep.localCenter;
|
||||
m_sweep.c.x = _loc4_.col1.x * _loc3_.x + _loc4_.col2.x * _loc3_.y;
|
||||
m_sweep.c.y = _loc4_.col1.y * _loc3_.x + _loc4_.col2.y * _loc3_.y;
|
||||
m_sweep.c.x += m_xf.position.x;
|
||||
m_sweep.c.y += m_xf.position.y;
|
||||
m_sweep.c0.SetV(m_sweep.c);
|
||||
_loc2_ = m_shapeList;
|
||||
while(_loc2_)
|
||||
{
|
||||
_loc2_.UpdateSweepRadius(m_sweep.localCenter);
|
||||
_loc2_ = _loc2_.m_next;
|
||||
}
|
||||
var _loc5_:int = m_type;
|
||||
if(m_invMass == 0 && m_invI == 0)
|
||||
{
|
||||
m_type = e_staticType;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_type = e_dynamicType;
|
||||
}
|
||||
if(_loc5_ != m_type)
|
||||
{
|
||||
_loc2_ = m_shapeList;
|
||||
while(_loc2_)
|
||||
{
|
||||
_loc2_.RefilterProxy(m_world.m_broadPhase,m_xf);
|
||||
_loc2_ = _loc2_.m_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function SetMassFromShapes() : void
|
||||
{
|
||||
var _loc3_:b2Shape = null;
|
||||
if(m_world.m_lock == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_mass = 0;
|
||||
m_invMass = 0;
|
||||
m_I = 0;
|
||||
m_invI = 0;
|
||||
var _loc4_:Number = 0;
|
||||
var _loc2_:Number = 0;
|
||||
var _loc1_:b2MassData = s_massData;
|
||||
_loc3_ = m_shapeList;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc3_.ComputeMass(_loc1_);
|
||||
m_mass += _loc1_.mass;
|
||||
_loc4_ += _loc1_.mass * _loc1_.center.x;
|
||||
_loc2_ += _loc1_.mass * _loc1_.center.y;
|
||||
m_I += _loc1_.I;
|
||||
_loc3_ = _loc3_.m_next;
|
||||
}
|
||||
if(m_mass > 0)
|
||||
{
|
||||
m_invMass = 1 / m_mass;
|
||||
_loc4_ *= m_invMass;
|
||||
_loc2_ *= m_invMass;
|
||||
}
|
||||
if(m_I > 0 && (m_flags & e_fixedRotationFlag) == 0)
|
||||
{
|
||||
m_I -= m_mass * (_loc4_ * _loc4_ + _loc2_ * _loc2_);
|
||||
m_invI = 1 / m_I;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_I = 0;
|
||||
m_invI = 0;
|
||||
}
|
||||
m_sweep.localCenter.Set(_loc4_,_loc2_);
|
||||
var _loc6_:b2Mat22 = m_xf.R;
|
||||
var _loc5_:b2Vec2 = m_sweep.localCenter;
|
||||
m_sweep.c.x = _loc6_.col1.x * _loc5_.x + _loc6_.col2.x * _loc5_.y;
|
||||
m_sweep.c.y = _loc6_.col1.y * _loc5_.x + _loc6_.col2.y * _loc5_.y;
|
||||
m_sweep.c.x += m_xf.position.x;
|
||||
m_sweep.c.y += m_xf.position.y;
|
||||
m_sweep.c0.SetV(m_sweep.c);
|
||||
_loc3_ = m_shapeList;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc3_.UpdateSweepRadius(m_sweep.localCenter);
|
||||
_loc3_ = _loc3_.m_next;
|
||||
}
|
||||
var _loc7_:int = m_type;
|
||||
if(m_invMass == 0 && m_invI == 0)
|
||||
{
|
||||
m_type = e_staticType;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_type = e_dynamicType;
|
||||
}
|
||||
if(_loc7_ != m_type)
|
||||
{
|
||||
_loc3_ = m_shapeList;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc3_.RefilterProxy(m_world.m_broadPhase,m_xf);
|
||||
_loc3_ = _loc3_.m_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function SetXForm(param1:b2Vec2, param2:Number) : Boolean
|
||||
{
|
||||
var _loc3_:b2Shape = null;
|
||||
var _loc7_:Boolean = false;
|
||||
if(m_world.m_lock == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(IsFrozen())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
m_xf.R.Set(param2);
|
||||
m_xf.position.SetV(param1);
|
||||
var _loc6_:b2Mat22 = m_xf.R;
|
||||
var _loc5_:b2Vec2 = m_sweep.localCenter;
|
||||
m_sweep.c.x = _loc6_.col1.x * _loc5_.x + _loc6_.col2.x * _loc5_.y;
|
||||
m_sweep.c.y = _loc6_.col1.y * _loc5_.x + _loc6_.col2.y * _loc5_.y;
|
||||
m_sweep.c.x += m_xf.position.x;
|
||||
m_sweep.c.y += m_xf.position.y;
|
||||
m_sweep.c0.SetV(m_sweep.c);
|
||||
m_sweep.a0 = m_sweep.a = param2;
|
||||
var _loc4_:Boolean = false;
|
||||
_loc3_ = m_shapeList;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc7_ = _loc3_.Synchronize(m_world.m_broadPhase,m_xf,m_xf);
|
||||
if(_loc7_ == false)
|
||||
{
|
||||
_loc4_ = true;
|
||||
break;
|
||||
}
|
||||
_loc3_ = _loc3_.m_next;
|
||||
}
|
||||
if(_loc4_ == true)
|
||||
{
|
||||
m_flags |= e_frozenFlag;
|
||||
m_linearVelocity.SetZero();
|
||||
m_angularVelocity = 0;
|
||||
_loc3_ = m_shapeList;
|
||||
while(_loc3_)
|
||||
{
|
||||
_loc3_.DestroyProxy(m_world.m_broadPhase);
|
||||
_loc3_ = _loc3_.m_next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
m_world.m_broadPhase.Commit();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function GetXForm() : b2XForm
|
||||
{
|
||||
return m_xf;
|
||||
}
|
||||
|
||||
public function GetPosition() : b2Vec2
|
||||
{
|
||||
return m_xf.position;
|
||||
}
|
||||
|
||||
public function GetAngle() : Number
|
||||
{
|
||||
return m_sweep.a;
|
||||
}
|
||||
|
||||
public function GetWorldCenter() : b2Vec2
|
||||
{
|
||||
return m_sweep.c;
|
||||
}
|
||||
|
||||
public function GetLocalCenter() : b2Vec2
|
||||
{
|
||||
return m_sweep.localCenter;
|
||||
}
|
||||
|
||||
public function SetLinearVelocity(param1:b2Vec2) : void
|
||||
{
|
||||
m_linearVelocity.SetV(param1);
|
||||
}
|
||||
|
||||
public function GetLinearVelocity() : b2Vec2
|
||||
{
|
||||
return m_linearVelocity;
|
||||
}
|
||||
|
||||
public function SetAngularVelocity(param1:Number) : void
|
||||
{
|
||||
m_angularVelocity = param1;
|
||||
}
|
||||
|
||||
public function GetAngularVelocity() : Number
|
||||
{
|
||||
return m_angularVelocity;
|
||||
}
|
||||
|
||||
public function ApplyForce(param1:b2Vec2, param2:b2Vec2) : void
|
||||
{
|
||||
if(IsSleeping())
|
||||
{
|
||||
WakeUp();
|
||||
}
|
||||
m_force.x += param1.x;
|
||||
m_force.y += param1.y;
|
||||
m_torque += (param2.x - m_sweep.c.x) * param1.y - (param2.y - m_sweep.c.y) * param1.x;
|
||||
}
|
||||
|
||||
public function ApplyTorque(param1:Number) : void
|
||||
{
|
||||
if(IsSleeping())
|
||||
{
|
||||
WakeUp();
|
||||
}
|
||||
m_torque += param1;
|
||||
}
|
||||
|
||||
public function ApplyImpulse(param1:b2Vec2, param2:b2Vec2) : void
|
||||
{
|
||||
if(IsSleeping())
|
||||
{
|
||||
WakeUp();
|
||||
}
|
||||
m_linearVelocity.x += m_invMass * param1.x;
|
||||
m_linearVelocity.y += m_invMass * param1.y;
|
||||
m_angularVelocity += m_invI * ((param2.x - m_sweep.c.x) * param1.y - (param2.y - m_sweep.c.y) * param1.x);
|
||||
}
|
||||
|
||||
public function GetMass() : Number
|
||||
{
|
||||
return m_mass;
|
||||
}
|
||||
|
||||
public function GetInertia() : Number
|
||||
{
|
||||
return m_I;
|
||||
}
|
||||
|
||||
public function GetWorldPoint(param1:b2Vec2) : b2Vec2
|
||||
{
|
||||
var _loc2_:b2Mat22 = m_xf.R;
|
||||
var _loc3_:b2Vec2 = new b2Vec2(_loc2_.col1.x * param1.x + _loc2_.col2.x * param1.y,_loc2_.col1.y * param1.x + _loc2_.col2.y * param1.y);
|
||||
_loc3_.x += m_xf.position.x;
|
||||
_loc3_.y += m_xf.position.y;
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public function GetWorldVector(param1:b2Vec2) : b2Vec2
|
||||
{
|
||||
return b2Math.b2MulMV(m_xf.R,param1);
|
||||
}
|
||||
|
||||
public function GetLocalPoint(param1:b2Vec2) : b2Vec2
|
||||
{
|
||||
return b2Math.b2MulXT(m_xf,param1);
|
||||
}
|
||||
|
||||
public function GetLocalVector(param1:b2Vec2) : b2Vec2
|
||||
{
|
||||
return b2Math.b2MulTMV(m_xf.R,param1);
|
||||
}
|
||||
|
||||
public function GetLinearVelocityFromWorldPoint(param1:b2Vec2) : b2Vec2
|
||||
{
|
||||
return new b2Vec2(m_linearVelocity.x - m_angularVelocity * (param1.y - m_sweep.c.y),m_linearVelocity.y + m_angularVelocity * (param1.x - m_sweep.c.x));
|
||||
}
|
||||
|
||||
public function GetLinearVelocityFromLocalPoint(param1:b2Vec2) : b2Vec2
|
||||
{
|
||||
var _loc2_:b2Mat22 = m_xf.R;
|
||||
var _loc3_:b2Vec2 = new b2Vec2(_loc2_.col1.x * param1.x + _loc2_.col2.x * param1.y,_loc2_.col1.y * param1.x + _loc2_.col2.y * param1.y);
|
||||
_loc3_.x += m_xf.position.x;
|
||||
_loc3_.y += m_xf.position.y;
|
||||
return new b2Vec2(m_linearVelocity.x + m_angularVelocity * (_loc3_.y - m_sweep.c.y),m_linearVelocity.x - m_angularVelocity * (_loc3_.x - m_sweep.c.x));
|
||||
}
|
||||
|
||||
public function IsBullet() : Boolean
|
||||
{
|
||||
return (m_flags & e_bulletFlag) == e_bulletFlag;
|
||||
}
|
||||
|
||||
public function SetBullet(param1:Boolean) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
m_flags |= e_bulletFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flags &= ~e_bulletFlag;
|
||||
}
|
||||
}
|
||||
|
||||
public function IsStatic() : Boolean
|
||||
{
|
||||
return m_type == e_staticType;
|
||||
}
|
||||
|
||||
public function IsDynamic() : Boolean
|
||||
{
|
||||
return m_type == e_dynamicType;
|
||||
}
|
||||
|
||||
public function IsFrozen() : Boolean
|
||||
{
|
||||
return (m_flags & e_frozenFlag) == e_frozenFlag;
|
||||
}
|
||||
|
||||
public function IsSleeping() : Boolean
|
||||
{
|
||||
return (m_flags & e_sleepFlag) == e_sleepFlag;
|
||||
}
|
||||
|
||||
public function AllowSleeping(param1:Boolean) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
m_flags |= e_allowSleepFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_flags &= ~e_allowSleepFlag;
|
||||
WakeUp();
|
||||
}
|
||||
}
|
||||
|
||||
public function WakeUp() : void
|
||||
{
|
||||
m_flags &= ~e_sleepFlag;
|
||||
m_sleepTime = 0;
|
||||
}
|
||||
|
||||
public function PutToSleep() : void
|
||||
{
|
||||
m_flags |= e_sleepFlag;
|
||||
m_sleepTime = 0;
|
||||
m_linearVelocity.SetZero();
|
||||
m_angularVelocity = 0;
|
||||
m_force.SetZero();
|
||||
m_torque = 0;
|
||||
}
|
||||
|
||||
public function GetShapeList() : b2Shape
|
||||
{
|
||||
return m_shapeList;
|
||||
}
|
||||
|
||||
public function GetJointList() : b2JointEdge
|
||||
{
|
||||
return m_jointList;
|
||||
}
|
||||
|
||||
public function GetNext() : b2Body
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
public function GetUserData() : *
|
||||
{
|
||||
return m_userData;
|
||||
}
|
||||
|
||||
public function SetUserData(param1:*) : void
|
||||
{
|
||||
m_userData = param1;
|
||||
}
|
||||
|
||||
public function GetWorld() : b2World
|
||||
{
|
||||
return m_world;
|
||||
}
|
||||
|
||||
public function SynchronizeShapes() : Boolean
|
||||
{
|
||||
var _loc2_:b2Shape = null;
|
||||
var _loc1_:b2XForm = s_xf1;
|
||||
_loc1_.R.Set(m_sweep.a0);
|
||||
var _loc4_:b2Mat22 = _loc1_.R;
|
||||
var _loc3_:b2Vec2 = m_sweep.localCenter;
|
||||
_loc1_.position.x = m_sweep.c0.x - (_loc4_.col1.x * _loc3_.x + _loc4_.col2.x * _loc3_.y);
|
||||
_loc1_.position.y = m_sweep.c0.y - (_loc4_.col1.y * _loc3_.x + _loc4_.col2.y * _loc3_.y);
|
||||
var _loc5_:Boolean = true;
|
||||
_loc2_ = m_shapeList;
|
||||
while(_loc2_)
|
||||
{
|
||||
_loc5_ = _loc2_.Synchronize(m_world.m_broadPhase,_loc1_,m_xf);
|
||||
if(_loc5_ == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc2_ = _loc2_.m_next;
|
||||
}
|
||||
if(_loc5_ == false)
|
||||
{
|
||||
m_flags |= e_frozenFlag;
|
||||
m_linearVelocity.SetZero();
|
||||
m_angularVelocity = 0;
|
||||
_loc2_ = m_shapeList;
|
||||
while(_loc2_)
|
||||
{
|
||||
_loc2_.DestroyProxy(m_world.m_broadPhase);
|
||||
_loc2_ = _loc2_.m_next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function SynchronizeTransform() : void
|
||||
{
|
||||
m_xf.R.Set(m_sweep.a);
|
||||
var _loc2_:b2Mat22 = m_xf.R;
|
||||
var _loc1_:b2Vec2 = m_sweep.localCenter;
|
||||
m_xf.position.x = m_sweep.c.x - (_loc2_.col1.x * _loc1_.x + _loc2_.col2.x * _loc1_.y);
|
||||
m_xf.position.y = m_sweep.c.y - (_loc2_.col1.y * _loc1_.x + _loc2_.col2.y * _loc1_.y);
|
||||
}
|
||||
|
||||
public function IsConnected(param1:b2Body) : Boolean
|
||||
{
|
||||
var _loc2_:b2JointEdge = null;
|
||||
_loc2_ = m_jointList;
|
||||
while(_loc2_)
|
||||
{
|
||||
if(_loc2_.other == param1)
|
||||
{
|
||||
return _loc2_.joint.m_collideConnected == false;
|
||||
}
|
||||
_loc2_ = _loc2_.next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function Advance(param1:Number) : void
|
||||
{
|
||||
m_sweep.Advance(param1);
|
||||
m_sweep.c.SetV(m_sweep.c0);
|
||||
m_sweep.a = m_sweep.a0;
|
||||
SynchronizeTransform();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2MassData;
|
||||
import Box2D.Common.Math.b2Vec2;
|
||||
|
||||
public class b2BodyDef
|
||||
{
|
||||
|
||||
public var massData:b2MassData = new b2MassData();
|
||||
|
||||
public var userData:*;
|
||||
|
||||
public var position:b2Vec2 = new b2Vec2();
|
||||
|
||||
public var angle:Number;
|
||||
|
||||
public var linearDamping:Number;
|
||||
|
||||
public var angularDamping:Number;
|
||||
|
||||
public var allowSleep:Boolean;
|
||||
|
||||
public var isSleeping:Boolean;
|
||||
|
||||
public var fixedRotation:Boolean;
|
||||
|
||||
public var isBullet:Boolean;
|
||||
|
||||
public function b2BodyDef()
|
||||
{
|
||||
super();
|
||||
massData.center.SetZero();
|
||||
massData.mass = 0;
|
||||
massData.I = 0;
|
||||
userData = null;
|
||||
position.Set(0,0);
|
||||
angle = 0;
|
||||
linearDamping = 0;
|
||||
angularDamping = 0;
|
||||
allowSleep = true;
|
||||
isSleeping = false;
|
||||
fixedRotation = false;
|
||||
isBullet = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
public class b2BoundaryListener
|
||||
{
|
||||
|
||||
public function b2BoundaryListener()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function Violation(param1:b2Body) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2FilterData;
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
|
||||
public class b2ContactFilter
|
||||
{
|
||||
|
||||
public static var b2_defaultFilter:b2ContactFilter = new b2ContactFilter();
|
||||
|
||||
public function b2ContactFilter()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function ShouldCollide(param1:b2Shape, param2:b2Shape) : Boolean
|
||||
{
|
||||
var _loc3_:b2FilterData = param1.GetFilterData();
|
||||
var _loc5_:b2FilterData = param2.GetFilterData();
|
||||
if(_loc3_.groupIndex == _loc5_.groupIndex && _loc3_.groupIndex != 0)
|
||||
{
|
||||
return _loc3_.groupIndex > 0;
|
||||
}
|
||||
return (_loc3_.maskBits & _loc5_.categoryBits) != 0 && (_loc3_.categoryBits & _loc5_.maskBits) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
import Box2D.Collision.b2ContactPoint;
|
||||
import Box2D.Dynamics.Contacts.b2ContactResult;
|
||||
|
||||
public class b2ContactListener
|
||||
{
|
||||
|
||||
public function b2ContactListener()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function Add(param1:b2ContactPoint) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function Persist(param1:b2ContactPoint) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function Remove(param1:b2ContactPoint) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function Result(param1:b2ContactResult) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Collision.Shapes.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.Contacts.*;
|
||||
|
||||
public class b2ContactManager extends b2PairCallback
|
||||
{
|
||||
|
||||
private static const s_evalCP:b2ContactPoint = new b2ContactPoint();
|
||||
|
||||
public var m_world:b2World;
|
||||
|
||||
public var m_nullContact:b2NullContact = new b2NullContact();
|
||||
|
||||
public var m_destroyImmediate:Boolean;
|
||||
|
||||
public function b2ContactManager()
|
||||
{
|
||||
super();
|
||||
m_world = null;
|
||||
m_destroyImmediate = false;
|
||||
}
|
||||
|
||||
override public function PairAdded(param1:*, param2:*) : *
|
||||
{
|
||||
var _loc4_:b2Shape = param1 as b2Shape;
|
||||
var _loc5_:b2Shape = param2 as b2Shape;
|
||||
var _loc6_:b2Body = _loc4_.m_body;
|
||||
var _loc7_:b2Body = _loc5_.m_body;
|
||||
if(_loc6_.IsStatic() && _loc7_.IsStatic())
|
||||
{
|
||||
return m_nullContact;
|
||||
}
|
||||
if(_loc4_.m_body == _loc5_.m_body)
|
||||
{
|
||||
return m_nullContact;
|
||||
}
|
||||
if(_loc7_.IsConnected(_loc6_))
|
||||
{
|
||||
return m_nullContact;
|
||||
}
|
||||
if(m_world.m_contactFilter != null && m_world.m_contactFilter.ShouldCollide(_loc4_,_loc5_) == false)
|
||||
{
|
||||
return m_nullContact;
|
||||
}
|
||||
var _loc3_:b2Contact = b2Contact.Create(_loc4_,_loc5_,m_world.m_blockAllocator);
|
||||
if(_loc3_ == null)
|
||||
{
|
||||
return m_nullContact;
|
||||
}
|
||||
_loc4_ = _loc3_.m_shape1;
|
||||
_loc5_ = _loc3_.m_shape2;
|
||||
_loc6_ = _loc4_.m_body;
|
||||
_loc7_ = _loc5_.m_body;
|
||||
_loc3_.m_prev = null;
|
||||
_loc3_.m_next = m_world.m_contactList;
|
||||
if(m_world.m_contactList != null)
|
||||
{
|
||||
m_world.m_contactList.m_prev = _loc3_;
|
||||
}
|
||||
m_world.m_contactList = _loc3_;
|
||||
_loc3_.m_node1.contact = _loc3_;
|
||||
_loc3_.m_node1.other = _loc7_;
|
||||
_loc3_.m_node1.prev = null;
|
||||
_loc3_.m_node1.next = _loc6_.m_contactList;
|
||||
if(_loc6_.m_contactList != null)
|
||||
{
|
||||
_loc6_.m_contactList.prev = _loc3_.m_node1;
|
||||
}
|
||||
_loc6_.m_contactList = _loc3_.m_node1;
|
||||
_loc3_.m_node2.contact = _loc3_;
|
||||
_loc3_.m_node2.other = _loc6_;
|
||||
_loc3_.m_node2.prev = null;
|
||||
_loc3_.m_node2.next = _loc7_.m_contactList;
|
||||
if(_loc7_.m_contactList != null)
|
||||
{
|
||||
_loc7_.m_contactList.prev = _loc3_.m_node2;
|
||||
}
|
||||
_loc7_.m_contactList = _loc3_.m_node2;
|
||||
++m_world.m_contactCount;
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
override public function PairRemoved(param1:*, param2:*, param3:*) : void
|
||||
{
|
||||
if(param3 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc4_:b2Contact = param3 as b2Contact;
|
||||
if(_loc4_ == m_nullContact)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Destroy(_loc4_);
|
||||
}
|
||||
|
||||
public function Destroy(param1:b2Contact) : void
|
||||
{
|
||||
var _loc8_:b2Body = null;
|
||||
var _loc9_:b2Body = null;
|
||||
var _loc2_:Array = null;
|
||||
var _loc7_:b2ContactPoint = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc14_:b2Manifold = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc3_:b2ManifoldPoint = null;
|
||||
var _loc15_:b2Vec2 = null;
|
||||
var _loc16_:b2Vec2 = null;
|
||||
var _loc11_:b2Shape = param1.m_shape1;
|
||||
var _loc12_:b2Shape = param1.m_shape2;
|
||||
var _loc10_:int = param1.m_manifoldCount;
|
||||
if(_loc10_ > 0 && m_world.m_contactListener)
|
||||
{
|
||||
_loc8_ = _loc11_.m_body;
|
||||
_loc9_ = _loc12_.m_body;
|
||||
_loc2_ = param1.GetManifolds();
|
||||
_loc7_ = s_evalCP;
|
||||
_loc7_.shape1 = param1.m_shape1;
|
||||
_loc7_.shape2 = param1.m_shape2;
|
||||
_loc7_.friction = param1.m_friction;
|
||||
_loc7_.restitution = param1.m_restitution;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc10_)
|
||||
{
|
||||
_loc14_ = _loc2_[_loc5_];
|
||||
_loc7_.normal.SetV(_loc14_.normal);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc14_.pointCount)
|
||||
{
|
||||
_loc3_ = _loc14_.points[_loc6_];
|
||||
_loc7_.position = _loc8_.GetWorldPoint(_loc3_.localPoint1);
|
||||
_loc15_ = _loc8_.GetLinearVelocityFromLocalPoint(_loc3_.localPoint1);
|
||||
_loc16_ = _loc9_.GetLinearVelocityFromLocalPoint(_loc3_.localPoint2);
|
||||
_loc7_.velocity.Set(_loc16_.x - _loc15_.x,_loc16_.y - _loc15_.y);
|
||||
_loc7_.separation = _loc3_.separation;
|
||||
_loc7_.id.key = _loc3_.id._key;
|
||||
m_world.m_contactListener.Remove(_loc7_);
|
||||
_loc6_++;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
if(param1.m_prev)
|
||||
{
|
||||
param1.m_prev.m_next = param1.m_next;
|
||||
}
|
||||
if(param1.m_next)
|
||||
{
|
||||
param1.m_next.m_prev = param1.m_prev;
|
||||
}
|
||||
if(param1 == m_world.m_contactList)
|
||||
{
|
||||
m_world.m_contactList = param1.m_next;
|
||||
}
|
||||
var _loc13_:b2Body = _loc11_.m_body;
|
||||
var _loc4_:b2Body = _loc12_.m_body;
|
||||
if(param1.m_node1.prev)
|
||||
{
|
||||
param1.m_node1.prev.next = param1.m_node1.next;
|
||||
}
|
||||
if(param1.m_node1.next)
|
||||
{
|
||||
param1.m_node1.next.prev = param1.m_node1.prev;
|
||||
}
|
||||
if(param1.m_node1 == _loc13_.m_contactList)
|
||||
{
|
||||
_loc13_.m_contactList = param1.m_node1.next;
|
||||
}
|
||||
if(param1.m_node2.prev)
|
||||
{
|
||||
param1.m_node2.prev.next = param1.m_node2.next;
|
||||
}
|
||||
if(param1.m_node2.next)
|
||||
{
|
||||
param1.m_node2.next.prev = param1.m_node2.prev;
|
||||
}
|
||||
if(param1.m_node2 == _loc4_.m_contactList)
|
||||
{
|
||||
_loc4_.m_contactList = param1.m_node2.next;
|
||||
}
|
||||
b2Contact.Destroy(param1,m_world.m_blockAllocator);
|
||||
--m_world.m_contactCount;
|
||||
}
|
||||
|
||||
public function Collide() : void
|
||||
{
|
||||
var _loc1_:b2Contact = null;
|
||||
var _loc2_:b2Body = null;
|
||||
var _loc3_:b2Body = null;
|
||||
_loc1_ = m_world.m_contactList;
|
||||
while(_loc1_)
|
||||
{
|
||||
_loc2_ = _loc1_.m_shape1.m_body;
|
||||
_loc3_ = _loc1_.m_shape2.m_body;
|
||||
if(!(_loc2_.IsSleeping() && _loc3_.IsSleeping()))
|
||||
{
|
||||
_loc1_.Update(m_world.m_contactListener);
|
||||
}
|
||||
_loc1_ = _loc1_.m_next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Collision.Shapes.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.Contacts.*;
|
||||
import flash.display.Sprite;
|
||||
|
||||
public class b2DebugDraw
|
||||
{
|
||||
|
||||
public static var e_shapeBit:uint = 1;
|
||||
|
||||
public static var e_jointBit:uint = 2;
|
||||
|
||||
public static var e_coreShapeBit:uint = 4;
|
||||
|
||||
public static var e_aabbBit:uint = 8;
|
||||
|
||||
public static var e_obbBit:uint = 16;
|
||||
|
||||
public static var e_pairBit:uint = 32;
|
||||
|
||||
public static var e_centerOfMassBit:uint = 64;
|
||||
|
||||
public var m_drawFlags:uint;
|
||||
|
||||
public var m_sprite:Sprite;
|
||||
|
||||
public var m_drawScale:Number = 1;
|
||||
|
||||
public var m_lineThickness:Number = 1;
|
||||
|
||||
public var m_alpha:Number = 1;
|
||||
|
||||
public var m_fillAlpha:Number = 1;
|
||||
|
||||
public var m_xformScale:Number = 1;
|
||||
|
||||
public function b2DebugDraw()
|
||||
{
|
||||
super();
|
||||
m_drawFlags = 0;
|
||||
}
|
||||
|
||||
public function SetFlags(param1:uint) : void
|
||||
{
|
||||
m_drawFlags = param1;
|
||||
}
|
||||
|
||||
public function GetFlags() : uint
|
||||
{
|
||||
return m_drawFlags;
|
||||
}
|
||||
|
||||
public function AppendFlags(param1:uint) : void
|
||||
{
|
||||
m_drawFlags |= param1;
|
||||
}
|
||||
|
||||
public function ClearFlags(param1:uint) : void
|
||||
{
|
||||
m_drawFlags &= ~param1;
|
||||
}
|
||||
|
||||
public function DrawPolygon(param1:Array, param2:int, param3:b2Color) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
m_sprite.graphics.lineStyle(m_lineThickness,param3.color,m_alpha);
|
||||
m_sprite.graphics.moveTo(param1[0].x * m_drawScale,param1[0].y * m_drawScale);
|
||||
_loc4_ = 1;
|
||||
while(_loc4_ < param2)
|
||||
{
|
||||
m_sprite.graphics.lineTo(param1[_loc4_].x * m_drawScale,param1[_loc4_].y * m_drawScale);
|
||||
_loc4_++;
|
||||
}
|
||||
m_sprite.graphics.lineTo(param1[0].x * m_drawScale,param1[0].y * m_drawScale);
|
||||
}
|
||||
|
||||
public function DrawSolidPolygon(param1:Array, param2:int, param3:b2Color) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
m_sprite.graphics.lineStyle(m_lineThickness,param3.color,m_alpha);
|
||||
m_sprite.graphics.moveTo(param1[0].x * m_drawScale,param1[0].y * m_drawScale);
|
||||
m_sprite.graphics.beginFill(param3.color,m_fillAlpha);
|
||||
_loc4_ = 1;
|
||||
while(_loc4_ < param2)
|
||||
{
|
||||
m_sprite.graphics.lineTo(param1[_loc4_].x * m_drawScale,param1[_loc4_].y * m_drawScale);
|
||||
_loc4_++;
|
||||
}
|
||||
m_sprite.graphics.lineTo(param1[0].x * m_drawScale,param1[0].y * m_drawScale);
|
||||
m_sprite.graphics.endFill();
|
||||
}
|
||||
|
||||
public function DrawCircle(param1:b2Vec2, param2:Number, param3:b2Color) : void
|
||||
{
|
||||
m_sprite.graphics.lineStyle(m_lineThickness,param3.color,m_alpha);
|
||||
m_sprite.graphics.drawCircle(param1.x * m_drawScale,param1.y * m_drawScale,param2 * m_drawScale);
|
||||
}
|
||||
|
||||
public function DrawSolidCircle(param1:b2Vec2, param2:Number, param3:b2Vec2, param4:b2Color) : void
|
||||
{
|
||||
m_sprite.graphics.lineStyle(m_lineThickness,param4.color,m_alpha);
|
||||
m_sprite.graphics.moveTo(0,0);
|
||||
m_sprite.graphics.beginFill(param4.color,m_fillAlpha);
|
||||
m_sprite.graphics.drawCircle(param1.x * m_drawScale,param1.y * m_drawScale,param2 * m_drawScale);
|
||||
m_sprite.graphics.endFill();
|
||||
m_sprite.graphics.moveTo(param1.x * m_drawScale,param1.y * m_drawScale);
|
||||
m_sprite.graphics.lineTo((param1.x + param3.x * param2) * m_drawScale,(param1.y + param3.y * param2) * m_drawScale);
|
||||
}
|
||||
|
||||
public function DrawSegment(param1:b2Vec2, param2:b2Vec2, param3:b2Color) : void
|
||||
{
|
||||
m_sprite.graphics.lineStyle(m_lineThickness,param3.color,m_alpha);
|
||||
m_sprite.graphics.moveTo(param1.x * m_drawScale,param1.y * m_drawScale);
|
||||
m_sprite.graphics.lineTo(param2.x * m_drawScale,param2.y * m_drawScale);
|
||||
}
|
||||
|
||||
public function DrawXForm(param1:b2XForm) : void
|
||||
{
|
||||
m_sprite.graphics.lineStyle(m_lineThickness,16711680,m_alpha);
|
||||
m_sprite.graphics.moveTo(param1.position.x * m_drawScale,param1.position.y * m_drawScale);
|
||||
m_sprite.graphics.lineTo((param1.position.x + m_xformScale * param1.R.col1.x) * m_drawScale,(param1.position.y + m_xformScale * param1.R.col1.y) * m_drawScale);
|
||||
m_sprite.graphics.lineStyle(m_lineThickness,65280,m_alpha);
|
||||
m_sprite.graphics.moveTo(param1.position.x * m_drawScale,param1.position.y * m_drawScale);
|
||||
m_sprite.graphics.lineTo((param1.position.x + m_xformScale * param1.R.col2.x) * m_drawScale,(param1.position.y + m_xformScale * param1.R.col2.y) * m_drawScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
import Box2D.Collision.Shapes.b2Shape;
|
||||
import Box2D.Dynamics.Joints.b2Joint;
|
||||
|
||||
public class b2DestructionListener
|
||||
{
|
||||
|
||||
public function b2DestructionListener()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function SayGoodbyeJoint(param1:b2Joint) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function SayGoodbyeShape(param1:b2Shape) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,349 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
import Box2D.Collision.*;
|
||||
import Box2D.Common.*;
|
||||
import Box2D.Common.Math.*;
|
||||
import Box2D.Dynamics.Contacts.*;
|
||||
import Box2D.Dynamics.Joints.*;
|
||||
|
||||
public class b2Island
|
||||
{
|
||||
|
||||
private static var s_reportCR:b2ContactResult = new b2ContactResult();
|
||||
|
||||
public var m_allocator:*;
|
||||
|
||||
public var m_listener:b2ContactListener;
|
||||
|
||||
public var m_bodies:Array;
|
||||
|
||||
public var m_contacts:Array;
|
||||
|
||||
public var m_joints:Array;
|
||||
|
||||
public var m_bodyCount:int;
|
||||
|
||||
public var m_jointCount:int;
|
||||
|
||||
public var m_contactCount:int;
|
||||
|
||||
public var m_bodyCapacity:int;
|
||||
|
||||
public var m_contactCapacity:int;
|
||||
|
||||
public var m_jointCapacity:int;
|
||||
|
||||
public var m_positionIterationCount:int;
|
||||
|
||||
public function b2Island(param1:int, param2:int, param3:int, param4:*, param5:b2ContactListener)
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
super();
|
||||
m_bodyCapacity = param1;
|
||||
m_contactCapacity = param2;
|
||||
m_jointCapacity = param3;
|
||||
m_bodyCount = 0;
|
||||
m_contactCount = 0;
|
||||
m_jointCount = 0;
|
||||
m_allocator = param4;
|
||||
m_listener = param5;
|
||||
m_bodies = new Array(param1);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < param1)
|
||||
{
|
||||
m_bodies[_loc6_] = null;
|
||||
_loc6_++;
|
||||
}
|
||||
m_contacts = new Array(param2);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < param2)
|
||||
{
|
||||
m_contacts[_loc6_] = null;
|
||||
_loc6_++;
|
||||
}
|
||||
m_joints = new Array(param3);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < param3)
|
||||
{
|
||||
m_joints[_loc6_] = null;
|
||||
_loc6_++;
|
||||
}
|
||||
m_positionIterationCount = 0;
|
||||
}
|
||||
|
||||
public function Clear() : void
|
||||
{
|
||||
m_bodyCount = 0;
|
||||
m_contactCount = 0;
|
||||
m_jointCount = 0;
|
||||
}
|
||||
|
||||
public function Solve(param1:b2TimeStep, param2:b2Vec2, param3:Boolean, param4:Boolean) : void
|
||||
{
|
||||
var _loc7_:int = 0;
|
||||
var _loc5_:b2Body = null;
|
||||
var _loc6_:b2Joint = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc10_:Boolean = false;
|
||||
var _loc12_:Boolean = false;
|
||||
var _loc14_:Boolean = false;
|
||||
var _loc15_:Number = NaN;
|
||||
var _loc13_:Number = NaN;
|
||||
var _loc9_:Number = NaN;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_bodyCount)
|
||||
{
|
||||
_loc5_ = m_bodies[_loc7_];
|
||||
if(!_loc5_.IsStatic())
|
||||
{
|
||||
_loc5_.m_linearVelocity.x += param1.dt * (param2.x + _loc5_.m_invMass * _loc5_.m_force.x);
|
||||
_loc5_.m_linearVelocity.y += param1.dt * (param2.y + _loc5_.m_invMass * _loc5_.m_force.y);
|
||||
_loc5_.m_angularVelocity += param1.dt * _loc5_.m_invI * _loc5_.m_torque;
|
||||
_loc5_.m_force.SetZero();
|
||||
_loc5_.m_torque = 0;
|
||||
_loc5_.m_linearVelocity.Multiply(b2Math.b2Clamp(1 - param1.dt * _loc5_.m_linearDamping,0,1));
|
||||
_loc5_.m_angularVelocity *= b2Math.b2Clamp(1 - param1.dt * _loc5_.m_angularDamping,0,1);
|
||||
if(_loc5_.m_linearVelocity.LengthSquared() > 40000)
|
||||
{
|
||||
_loc5_.m_linearVelocity.Normalize();
|
||||
_loc5_.m_linearVelocity.x *= 200;
|
||||
_loc5_.m_linearVelocity.y *= 200;
|
||||
}
|
||||
if(_loc5_.m_angularVelocity * _loc5_.m_angularVelocity > 62500)
|
||||
{
|
||||
if(_loc5_.m_angularVelocity < 0)
|
||||
{
|
||||
_loc5_.m_angularVelocity = -250;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.m_angularVelocity = 250;
|
||||
}
|
||||
}
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
var _loc11_:b2ContactSolver = new b2ContactSolver(param1,m_contacts,m_contactCount,m_allocator);
|
||||
_loc11_.InitVelocityConstraints(param1);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_jointCount)
|
||||
{
|
||||
_loc6_ = m_joints[_loc7_];
|
||||
_loc6_.InitVelocityConstraints(param1);
|
||||
_loc7_++;
|
||||
}
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < param1.maxIterations)
|
||||
{
|
||||
_loc11_.SolveVelocityConstraints();
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < m_jointCount)
|
||||
{
|
||||
_loc6_ = m_joints[_loc8_];
|
||||
_loc6_.SolveVelocityConstraints(param1);
|
||||
_loc8_++;
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
_loc11_.FinalizeVelocityConstraints();
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_bodyCount)
|
||||
{
|
||||
_loc5_ = m_bodies[_loc7_];
|
||||
if(!_loc5_.IsStatic())
|
||||
{
|
||||
_loc5_.m_sweep.c0.SetV(_loc5_.m_sweep.c);
|
||||
_loc5_.m_sweep.a0 = _loc5_.m_sweep.a;
|
||||
_loc5_.m_sweep.c.x += param1.dt * _loc5_.m_linearVelocity.x;
|
||||
_loc5_.m_sweep.c.y += param1.dt * _loc5_.m_linearVelocity.y;
|
||||
_loc5_.m_sweep.a += param1.dt * _loc5_.m_angularVelocity;
|
||||
_loc5_.SynchronizeTransform();
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
if(param3)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_jointCount)
|
||||
{
|
||||
_loc6_ = m_joints[_loc7_];
|
||||
_loc6_.InitPositionConstraints();
|
||||
_loc7_++;
|
||||
}
|
||||
m_positionIterationCount = 0;
|
||||
while(m_positionIterationCount < param1.maxIterations)
|
||||
{
|
||||
_loc10_ = _loc11_.SolvePositionConstraints(0.2);
|
||||
_loc12_ = true;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_jointCount)
|
||||
{
|
||||
_loc6_ = m_joints[_loc7_];
|
||||
_loc14_ = _loc6_.SolvePositionConstraints();
|
||||
_loc12_ &&= _loc14_;
|
||||
_loc7_++;
|
||||
}
|
||||
if(_loc10_ && _loc12_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
m_positionIterationCount = m_positionIterationCount + 1;
|
||||
}
|
||||
}
|
||||
Report(_loc11_.m_constraints);
|
||||
if(param4)
|
||||
{
|
||||
_loc15_ = 1.7976931348623157e+308;
|
||||
_loc13_ = 0.0001;
|
||||
_loc9_ = 0.0001234567901234568;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_bodyCount)
|
||||
{
|
||||
_loc5_ = m_bodies[_loc7_];
|
||||
if(_loc5_.m_invMass != 0)
|
||||
{
|
||||
if((_loc5_.m_flags & b2Body.e_allowSleepFlag) == 0)
|
||||
{
|
||||
_loc5_.m_sleepTime = 0;
|
||||
_loc15_ = 0;
|
||||
}
|
||||
if((_loc5_.m_flags & b2Body.e_allowSleepFlag) == 0 || _loc5_.m_angularVelocity * _loc5_.m_angularVelocity > _loc9_ || b2Math.b2Dot(_loc5_.m_linearVelocity,_loc5_.m_linearVelocity) > _loc13_)
|
||||
{
|
||||
_loc5_.m_sleepTime = 0;
|
||||
_loc15_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.m_sleepTime += param1.dt;
|
||||
_loc15_ = b2Math.b2Min(_loc15_,_loc5_.m_sleepTime);
|
||||
}
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
if(_loc15_ >= 0.5)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < m_bodyCount)
|
||||
{
|
||||
_loc5_ = m_bodies[_loc7_];
|
||||
_loc5_.m_flags = _loc5_.m_flags | b2Body.e_sleepFlag;
|
||||
_loc5_.m_linearVelocity.SetZero();
|
||||
_loc5_.m_angularVelocity = 0;
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function SolveTOI(param1:b2TimeStep) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:b2Body = null;
|
||||
var _loc3_:Boolean = false;
|
||||
var _loc4_:b2ContactSolver = new b2ContactSolver(param1,m_contacts,m_contactCount,m_allocator);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < param1.maxIterations)
|
||||
{
|
||||
_loc4_.SolveVelocityConstraints();
|
||||
_loc5_++;
|
||||
}
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < m_bodyCount)
|
||||
{
|
||||
_loc2_ = m_bodies[_loc5_];
|
||||
if(!_loc2_.IsStatic())
|
||||
{
|
||||
_loc2_.m_sweep.c0.SetV(_loc2_.m_sweep.c);
|
||||
_loc2_.m_sweep.a0 = _loc2_.m_sweep.a;
|
||||
_loc2_.m_sweep.c.x += param1.dt * _loc2_.m_linearVelocity.x;
|
||||
_loc2_.m_sweep.c.y += param1.dt * _loc2_.m_linearVelocity.y;
|
||||
_loc2_.m_sweep.a += param1.dt * _loc2_.m_angularVelocity;
|
||||
_loc2_.SynchronizeTransform();
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc6_:Number = 0.75;
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < param1.maxIterations)
|
||||
{
|
||||
_loc3_ = _loc4_.SolvePositionConstraints(_loc6_);
|
||||
if(_loc3_)
|
||||
{
|
||||
break;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
Report(_loc4_.m_constraints);
|
||||
}
|
||||
|
||||
public function Report(param1:Array) : void
|
||||
{
|
||||
var _loc14_:* = null;
|
||||
var _loc13_:* = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:b2Contact = null;
|
||||
var _loc2_:b2ContactConstraint = null;
|
||||
var _loc9_:b2ContactResult = null;
|
||||
var _loc10_:b2Body = null;
|
||||
var _loc11_:int = 0;
|
||||
var _loc3_:Array = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc15_:b2Manifold = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:b2ManifoldPoint = null;
|
||||
var _loc12_:b2ContactConstraintPoint = null;
|
||||
if(m_listener == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < m_contactCount)
|
||||
{
|
||||
_loc4_ = m_contacts[_loc5_];
|
||||
_loc2_ = param1[_loc5_];
|
||||
_loc9_ = s_reportCR;
|
||||
_loc9_.shape1 = _loc4_.m_shape1;
|
||||
_loc9_.shape2 = _loc4_.m_shape2;
|
||||
_loc10_ = _loc9_.shape1.m_body;
|
||||
_loc11_ = _loc4_.m_manifoldCount;
|
||||
_loc3_ = _loc4_.GetManifolds();
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc11_)
|
||||
{
|
||||
_loc15_ = _loc3_[_loc6_];
|
||||
_loc9_.normal.SetV(_loc15_.normal);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc15_.pointCount)
|
||||
{
|
||||
_loc8_ = _loc15_.points[_loc7_];
|
||||
_loc12_ = _loc2_.points[_loc7_];
|
||||
_loc9_.position = _loc10_.GetWorldPoint(_loc8_.localPoint1);
|
||||
_loc9_.normalImpulse = _loc12_.normalImpulse;
|
||||
_loc9_.tangentImpulse = _loc12_.tangentImpulse;
|
||||
_loc9_.id.key = _loc8_.id.key;
|
||||
m_listener.Result(_loc9_);
|
||||
_loc7_++;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
|
||||
public function AddBody(param1:b2Body) : void
|
||||
{
|
||||
m_bodies[m_bodyCount++] = param1;
|
||||
}
|
||||
|
||||
public function AddContact(param1:b2Contact) : void
|
||||
{
|
||||
m_contacts[m_contactCount++] = param1;
|
||||
}
|
||||
|
||||
public function AddJoint(param1:b2Joint) : void
|
||||
{
|
||||
m_joints[m_jointCount++] = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package Box2D.Dynamics
|
||||
{
|
||||
public class b2TimeStep
|
||||
{
|
||||
|
||||
public var dt:Number;
|
||||
|
||||
public var inv_dt:Number;
|
||||
|
||||
public var dtRatio:Number;
|
||||
|
||||
public var maxIterations:int;
|
||||
|
||||
public var warmStarting:Boolean;
|
||||
|
||||
public var positionCorrection:Boolean;
|
||||
|
||||
public function b2TimeStep()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,14 @@
|
||||
package
|
||||
{
|
||||
import flash.display.Sprite;
|
||||
|
||||
public dynamic class DisplayLayer extends Sprite
|
||||
{
|
||||
|
||||
public function DisplayLayer()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package Enums
|
||||
{
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class AdoptAPetDef
|
||||
{
|
||||
|
||||
private var _defId:int;
|
||||
|
||||
private var _titleStrId:int;
|
||||
|
||||
private var _mediaRefId:int;
|
||||
|
||||
private var _type:int;
|
||||
|
||||
private var _series:int;
|
||||
|
||||
private var _hidden:Boolean;
|
||||
|
||||
public function AdoptAPetDef(param1:int, param2:int, param3:int, param4:int, param5:int, param6:Boolean)
|
||||
{
|
||||
super();
|
||||
_defId = param1;
|
||||
_titleStrId = param2;
|
||||
_mediaRefId = param3;
|
||||
_type = param4;
|
||||
_series = param5;
|
||||
_hidden = param6;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return _defId;
|
||||
}
|
||||
|
||||
public function get titleStrId() : int
|
||||
{
|
||||
return _titleStrId;
|
||||
}
|
||||
|
||||
public function get mediaRefId() : int
|
||||
{
|
||||
return _mediaRefId;
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return LocalizationManager.translateIdOnly(_titleStrId);
|
||||
}
|
||||
|
||||
public function get type() : int
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public function get series() : int
|
||||
{
|
||||
return _series;
|
||||
}
|
||||
|
||||
public function get hidden() : Boolean
|
||||
{
|
||||
return _hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
package Enums
|
||||
{
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class DenItemDef
|
||||
{
|
||||
|
||||
public static var PROMO_TYPE_NONE:int = 0;
|
||||
|
||||
public static var PROMO_TYPE_MCD:int = 1;
|
||||
|
||||
private var _abbrName:String;
|
||||
|
||||
private var _combinedCurrencyString:String;
|
||||
|
||||
private var _cost:int;
|
||||
|
||||
private var _currencyType:int;
|
||||
|
||||
private var _enviroType:int;
|
||||
|
||||
private var _flag:int;
|
||||
|
||||
private var _gameDefId:int;
|
||||
|
||||
private var _id:int;
|
||||
|
||||
private var _itemStatus:int;
|
||||
|
||||
private var _layer:int;
|
||||
|
||||
private var _mannequinAvatarDefId:int;
|
||||
|
||||
private var _mannequinCatId:int;
|
||||
|
||||
private var _mannequinFrame:int;
|
||||
|
||||
private var _membersOnly:int;
|
||||
|
||||
private var _name:String;
|
||||
|
||||
private var _nameStrId:int;
|
||||
|
||||
private var _listId:int;
|
||||
|
||||
private var _promoType:int;
|
||||
|
||||
private var _recycleValue:int;
|
||||
|
||||
private var _scalePercent:int;
|
||||
|
||||
private var _sortCat:int;
|
||||
|
||||
private var _specialType:int;
|
||||
|
||||
private var _typeCat:int;
|
||||
|
||||
private var _isMasterpiece:Boolean;
|
||||
|
||||
private var _availabilityStartTime:uint;
|
||||
|
||||
private var _availabilityEndTime:uint;
|
||||
|
||||
private var _ecoPower:int;
|
||||
|
||||
public function DenItemDef(param1:String, param2:String, param3:int, param4:int, param5:int, param6:int, param7:int, param8:int, param9:int, param10:int, param11:int, param12:int, param13:int, param14:int, param15:int, param16:int, param17:int, param18:int, param19:int, param20:int, param21:int, param22:int, param23:uint, param24:uint, param25:int)
|
||||
{
|
||||
super();
|
||||
_abbrName = param1;
|
||||
_combinedCurrencyString = param2;
|
||||
_cost = param3;
|
||||
_currencyType = param4;
|
||||
_enviroType = param5;
|
||||
_flag = param6;
|
||||
_gameDefId = param7;
|
||||
_id = param8;
|
||||
_itemStatus = param9;
|
||||
_layer = param10;
|
||||
_mannequinAvatarDefId = param11;
|
||||
_mannequinCatId = param12;
|
||||
_mannequinFrame = param13;
|
||||
_membersOnly = param14;
|
||||
_name = LocalizationManager.translateIdOnly(param15);
|
||||
_nameStrId = param15;
|
||||
_listId = param16;
|
||||
_promoType = param17;
|
||||
_recycleValue = param18;
|
||||
_scalePercent = param19;
|
||||
_sortCat = param20;
|
||||
_specialType = param21;
|
||||
_typeCat = param22;
|
||||
_isMasterpiece = _id == 2725;
|
||||
_availabilityStartTime = param23;
|
||||
_availabilityEndTime = param24;
|
||||
_ecoPower = param25;
|
||||
}
|
||||
|
||||
public function get abbrName() : String
|
||||
{
|
||||
return _abbrName;
|
||||
}
|
||||
|
||||
public function get combinedCurrencyString() : String
|
||||
{
|
||||
return _combinedCurrencyString;
|
||||
}
|
||||
|
||||
public function get cost() : int
|
||||
{
|
||||
return _cost;
|
||||
}
|
||||
|
||||
public function get currencyType() : int
|
||||
{
|
||||
return _currencyType;
|
||||
}
|
||||
|
||||
public function get enviroType() : int
|
||||
{
|
||||
return _enviroType;
|
||||
}
|
||||
|
||||
public function get flag() : int
|
||||
{
|
||||
return _flag;
|
||||
}
|
||||
|
||||
public function get gameDefId() : int
|
||||
{
|
||||
return _gameDefId;
|
||||
}
|
||||
|
||||
public function get id() : int
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public function get itemStatus() : int
|
||||
{
|
||||
return _itemStatus;
|
||||
}
|
||||
|
||||
public function get layer() : int
|
||||
{
|
||||
return _layer;
|
||||
}
|
||||
|
||||
public function get mannequinAvatarDefId() : int
|
||||
{
|
||||
return _mannequinAvatarDefId;
|
||||
}
|
||||
|
||||
public function get mannequinCatId() : int
|
||||
{
|
||||
return _mannequinCatId;
|
||||
}
|
||||
|
||||
public function get mannequinFrame() : int
|
||||
{
|
||||
return _mannequinFrame;
|
||||
}
|
||||
|
||||
public function get isMembersOnly() : Boolean
|
||||
{
|
||||
return _membersOnly == 1;
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public function set name(param1:String) : void
|
||||
{
|
||||
_name = param1;
|
||||
}
|
||||
|
||||
public function get nameStrId() : int
|
||||
{
|
||||
return _nameStrId;
|
||||
}
|
||||
|
||||
public function get listId() : int
|
||||
{
|
||||
return _listId;
|
||||
}
|
||||
|
||||
public function get promoType() : int
|
||||
{
|
||||
return _promoType;
|
||||
}
|
||||
|
||||
public function get recycleValue() : int
|
||||
{
|
||||
return _recycleValue;
|
||||
}
|
||||
|
||||
public function get scalePercent() : int
|
||||
{
|
||||
return _scalePercent;
|
||||
}
|
||||
|
||||
public function get sortCat() : int
|
||||
{
|
||||
return _sortCat;
|
||||
}
|
||||
|
||||
public function get specialType() : int
|
||||
{
|
||||
return _specialType;
|
||||
}
|
||||
|
||||
public function get typeCat() : int
|
||||
{
|
||||
return _typeCat;
|
||||
}
|
||||
|
||||
public function get isMasterpiece() : Boolean
|
||||
{
|
||||
return _isMasterpiece;
|
||||
}
|
||||
|
||||
public function get availabilityStartTime() : uint
|
||||
{
|
||||
return _availabilityStartTime;
|
||||
}
|
||||
|
||||
public function get availabilityEndTime() : uint
|
||||
{
|
||||
return _availabilityEndTime;
|
||||
}
|
||||
|
||||
public function get ecoPower() : int
|
||||
{
|
||||
return _ecoPower;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package Enums
|
||||
{
|
||||
public class StreamDef
|
||||
{
|
||||
|
||||
private var _defId:int;
|
||||
|
||||
private var _thumbnailId:int;
|
||||
|
||||
private var _baseTitleId:int;
|
||||
|
||||
private var _individualTitleId:int;
|
||||
|
||||
private var _status:int;
|
||||
|
||||
private var _subtitleId:int;
|
||||
|
||||
public function StreamDef(param1:int, param2:int = 0, param3:String = "", param4:int = 0, param5:int = 0)
|
||||
{
|
||||
super();
|
||||
_defId = param1;
|
||||
_thumbnailId = param2;
|
||||
var _loc6_:Array = param3.split("|");
|
||||
_baseTitleId = _loc6_[0];
|
||||
if(_loc6_[1])
|
||||
{
|
||||
_individualTitleId = _loc6_[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
_individualTitleId = _loc6_[0];
|
||||
}
|
||||
_status = param4;
|
||||
_subtitleId = param5;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return _defId;
|
||||
}
|
||||
|
||||
public function get thumbnailId() : int
|
||||
{
|
||||
return _thumbnailId;
|
||||
}
|
||||
|
||||
public function get baseTitleId() : int
|
||||
{
|
||||
return _baseTitleId;
|
||||
}
|
||||
|
||||
public function get individualTitleId() : int
|
||||
{
|
||||
return _individualTitleId;
|
||||
}
|
||||
|
||||
public function get subtitleId() : int
|
||||
{
|
||||
return _subtitleId;
|
||||
}
|
||||
|
||||
public function set status(param1:int) : void
|
||||
{
|
||||
_status = param1;
|
||||
}
|
||||
|
||||
public function get isOnSale() : Boolean
|
||||
{
|
||||
return _status == 2;
|
||||
}
|
||||
|
||||
public function get isOnClearance() : Boolean
|
||||
{
|
||||
return _status == 3;
|
||||
}
|
||||
|
||||
public function get isRare() : Boolean
|
||||
{
|
||||
return _status == 4;
|
||||
}
|
||||
|
||||
public function get isNew() : Boolean
|
||||
{
|
||||
return _status == 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package Enums
|
||||
{
|
||||
public class TradeItem
|
||||
{
|
||||
|
||||
public static const ITEM_TYPE_ACCESSORY_ITEM:int = 0;
|
||||
|
||||
public static const ITEM_TYPE_DEN_ITEM:int = 1;
|
||||
|
||||
public static const ITEM_TYPE_AUDIO_ITEM:int = 2;
|
||||
|
||||
public static const ITEM_TYPE_PET_ITEM:int = 3;
|
||||
|
||||
private var _invIdx:int;
|
||||
|
||||
private var _itemType:int;
|
||||
|
||||
public function TradeItem(param1:int, param2:int)
|
||||
{
|
||||
super();
|
||||
_invIdx = param1;
|
||||
_itemType = param2;
|
||||
}
|
||||
|
||||
public function get invIdx() : int
|
||||
{
|
||||
return _invIdx;
|
||||
}
|
||||
|
||||
public function get itemType() : int
|
||||
{
|
||||
return _itemType;
|
||||
}
|
||||
|
||||
public function isEqual(param1:TradeItem) : Boolean
|
||||
{
|
||||
return _invIdx == param1.invIdx && _itemType == param1.itemType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package Enums
|
||||
{
|
||||
public class WorldItemDef
|
||||
{
|
||||
|
||||
public static const TYPE_DEN_ITEM:int = 0;
|
||||
|
||||
public static const TYPE_GEMS:int = 1;
|
||||
|
||||
public static const TYPE_DIAMONDS:int = 2;
|
||||
|
||||
public static const TYPE_ACCESSORY_ITEM:int = 3;
|
||||
|
||||
private var _defId:int;
|
||||
|
||||
private var _mediaRefId:int;
|
||||
|
||||
private var _descText:String;
|
||||
|
||||
private var _giftType:int;
|
||||
|
||||
private var _giftRefId:int;
|
||||
|
||||
private var _giftAmount:int;
|
||||
|
||||
private var _position:int;
|
||||
|
||||
private var _userVarRefId:int;
|
||||
|
||||
private var _userVarIndex:int;
|
||||
|
||||
private var _status:int;
|
||||
|
||||
private var _popupType:int;
|
||||
|
||||
private var _availabilityStartTime:uint;
|
||||
|
||||
private var _availabilityEndTime:uint;
|
||||
|
||||
public function WorldItemDef(param1:int, param2:int, param3:String, param4:int, param5:int, param6:int, param7:int, param8:int, param9:int, param10:int, param11:uint, param12:uint)
|
||||
{
|
||||
super();
|
||||
_defId = param1;
|
||||
_mediaRefId = param2;
|
||||
_descText = param3;
|
||||
_giftType = param4;
|
||||
_giftRefId = param5;
|
||||
_giftAmount = param6;
|
||||
_position = param7;
|
||||
_userVarRefId = param8;
|
||||
_userVarIndex = param9;
|
||||
_popupType = param10;
|
||||
_availabilityStartTime = param11;
|
||||
_availabilityEndTime = param12;
|
||||
}
|
||||
|
||||
public function get defId() : int
|
||||
{
|
||||
return _defId;
|
||||
}
|
||||
|
||||
public function get mediaRefId() : int
|
||||
{
|
||||
return _mediaRefId;
|
||||
}
|
||||
|
||||
public function get descText() : String
|
||||
{
|
||||
return _descText;
|
||||
}
|
||||
|
||||
public function get giftType() : int
|
||||
{
|
||||
return _giftType;
|
||||
}
|
||||
|
||||
public function get giftRefId() : int
|
||||
{
|
||||
return _giftRefId;
|
||||
}
|
||||
|
||||
public function get giftAmount() : int
|
||||
{
|
||||
return _giftAmount;
|
||||
}
|
||||
|
||||
public function get position() : int
|
||||
{
|
||||
return _position;
|
||||
}
|
||||
|
||||
public function get status() : int
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
public function set status(param1:int) : void
|
||||
{
|
||||
_status = param1;
|
||||
}
|
||||
|
||||
public function get userVarRefId() : int
|
||||
{
|
||||
return _userVarRefId;
|
||||
}
|
||||
|
||||
public function get userVarIndex() : int
|
||||
{
|
||||
return _userVarIndex;
|
||||
}
|
||||
|
||||
public function get popupType() : int
|
||||
{
|
||||
return _popupType;
|
||||
}
|
||||
|
||||
public function get isAvailable() : Boolean
|
||||
{
|
||||
return Utility.isAvailable(_availabilityStartTime,_availabilityEndTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.loader.ResourceStack;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public function GETDEFINITIONBYNAME(param1:String, param2:Boolean = true) : *
|
||||
{
|
||||
var _loc3_:Class = new (ResourceStack.hudAssetsLoaderInfo.applicationDomain.getDefinition(param1) as Class)();
|
||||
if(param2)
|
||||
{
|
||||
LocalizationManager.findAllTextfields(_loc3_);
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package
|
||||
{
|
||||
import flash.compiler.embed.EmbeddedMovieClip;
|
||||
|
||||
public class Game_Sign_swf extends EmbeddedMovieClip
|
||||
{
|
||||
|
||||
public function Game_Sign_swf()
|
||||
{
|
||||
super(new Game_Sign_swf_ByteArray(),100,150);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
[Embed(source="/_assets/5_Game_Sign_swf_ByteArray.bin", mimeType="application/octet-stream")]
|
||||
public class Game_Sign_swf_ByteArray extends ByteArray
|
||||
{
|
||||
|
||||
public function Game_Sign_swf_ByteArray()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,759 @@
|
||||
package
|
||||
{
|
||||
import Enums.StreamDef;
|
||||
import WorldItems.WorldItemsManager;
|
||||
import collection.BaseTypedCollection;
|
||||
import collection.IitemCollection;
|
||||
import collection.StreamDefCollection;
|
||||
import collection.WorldItemCollection;
|
||||
import com.sbi.client.SFEvent;
|
||||
import inventory.Iitem;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.DefPacksDefHelper;
|
||||
|
||||
public class GenericListXtCommManager
|
||||
{
|
||||
|
||||
public static const AVAIL_TYPE_CLOTHING:int = 0;
|
||||
|
||||
public static const AVAIL_TYPE_DEN_ACC:int = 1;
|
||||
|
||||
public static const AVAIL_TYPE_PARTY:int = 2;
|
||||
|
||||
public static const AVAIL_TYPE_DEN_ROOM:int = 3;
|
||||
|
||||
public static const AVAIL_TYPE_ROOM:int = 4;
|
||||
|
||||
public static const AVAIL_TYPE_STREAM:int = 5;
|
||||
|
||||
public static const AVAIL_TYPE_DIAMOND:int = 6;
|
||||
|
||||
public static const AVAIL_TYPE_AVATAR:int = 7;
|
||||
|
||||
public static const AVAIL_TYPE_PET:int = 8;
|
||||
|
||||
public static const AVAIL_TYPE_WORLD_ITEMS:int = 9;
|
||||
|
||||
public static const AVAIL_TYPE_NEWSPAPER:int = 10;
|
||||
|
||||
public static const ACC_JAMAA_SHOP_ID:int = 11;
|
||||
|
||||
public static const ACC_BAHARIBAY_SHOP_ID:int = 50;
|
||||
|
||||
public static const ACC_CHARM_SHOP_ID:int = 669;
|
||||
|
||||
public static const DEN_ITEM_MAIN_SHOP_ID:int = 12;
|
||||
|
||||
public static const DEN_ITEM_CRYSTALREEF_SHOP_ID:int = 51;
|
||||
|
||||
public static const DEN_ITEM_AUDIO_SHOP_ID:int = 56;
|
||||
|
||||
public static const DEN_ITEM_PET_LAND:int = 85;
|
||||
|
||||
public static const DEN_ITEM_PET_OCEAN:int = 89;
|
||||
|
||||
public static const DEN_ITEM_FIRST_TIME_SHOP_ID:int = 234;
|
||||
|
||||
public static const REDEMPTION_STORE_LIST_ID:int = 172;
|
||||
|
||||
public static const DEN_ROOM_SHOP_ID:int = 13;
|
||||
|
||||
public static const DEN_ROOM_FULL_SHOP_ID:int = 384;
|
||||
|
||||
public static const MEDIA_EBOOK_1_ID:int = 23;
|
||||
|
||||
public static const AVATAR_LIST_ID:int = 64;
|
||||
|
||||
public static const CURR_SHOP_DIAMOND_AVATAR_LIST:int = 166;
|
||||
|
||||
public static const DIAMOND_AVATAR_LIST_ID:int = 293;
|
||||
|
||||
public static const MEDIA_JAG_CARD_LIST_ID:int = 10;
|
||||
|
||||
public static const MEDIA_JAG_STAMP_LIST_ID:int = 44;
|
||||
|
||||
public static const DIAMOND_PET_LIST:int = 214;
|
||||
|
||||
public static const AVAILABLE_PET_LIST:int = 312;
|
||||
|
||||
public static const PERSONALITY_PET_LIST:int = 432;
|
||||
|
||||
public static const EGG_PET_LIST:int = 624;
|
||||
|
||||
public static const MASTERPIECE_ICON_LIST_ID:int = 416;
|
||||
|
||||
public static const MASTERPIECE_ICON_IN_DEN_ITEM_VERSION_ORDER:int = 424;
|
||||
|
||||
public static const PLATFORMER_LIST:int = 566;
|
||||
|
||||
private static var _requestCallbackQueue:Object;
|
||||
|
||||
private static var _requestPassbackQueue:Object;
|
||||
|
||||
private static var _streamQueue:Object;
|
||||
|
||||
private static var _cachedResponses:Object;
|
||||
|
||||
public function GenericListXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_cachedResponses = {};
|
||||
_requestCallbackQueue = {};
|
||||
_requestPassbackQueue = {};
|
||||
_streamQueue = {};
|
||||
XtReplyDemuxer.addModule(GenericListXtCommManager.handleXtReply,"g");
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function requestGenericList(param1:int, param2:Function = null, param3:Object = null, param4:Boolean = true) : void
|
||||
{
|
||||
var _loc5_:Boolean = true;
|
||||
if(_requestCallbackQueue[param1])
|
||||
{
|
||||
_requestCallbackQueue[param1].push(param2);
|
||||
_loc5_ = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_requestCallbackQueue[param1] = [param2];
|
||||
}
|
||||
if(_requestPassbackQueue[param1])
|
||||
{
|
||||
_requestPassbackQueue[param1].push(param3);
|
||||
}
|
||||
else
|
||||
{
|
||||
_requestPassbackQueue[param1] = [param3];
|
||||
}
|
||||
if(_cachedResponses[param1])
|
||||
{
|
||||
handleNewData(_cachedResponses[param1].concat());
|
||||
}
|
||||
else if(_loc5_)
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("gl",[param1],param4);
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestStreamList(param1:int, param2:Function, param3:Object = null) : void
|
||||
{
|
||||
_streamQueue[param1] = {
|
||||
"c":param2,
|
||||
"h":param3
|
||||
};
|
||||
if(_cachedResponses[param1])
|
||||
{
|
||||
handleNewData(_cachedResponses[param1].concat());
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("gl",[param1]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Array = param1.obj;
|
||||
if(_loc2_[0] == "gl")
|
||||
{
|
||||
_cachedResponses[int(_loc2_[2])] = _loc2_;
|
||||
}
|
||||
handleNewData(_loc2_.concat());
|
||||
}
|
||||
|
||||
public static function filterIitems(param1:IitemCollection, param2:Boolean = false, ... rest) : void
|
||||
{
|
||||
var _loc6_:Array = null;
|
||||
var _loc7_:int = 0;
|
||||
var _loc5_:Array = null;
|
||||
var _loc8_:int = 0;
|
||||
if(param1.length == 0 || !param1.getCoreArray()[0].hasOwnProperty("isAvailable"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc4_:int = 86400;
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < param1.length)
|
||||
{
|
||||
if(!param1.getIitem(_loc7_).isAvailable)
|
||||
{
|
||||
_loc6_ = param1.getCoreArray().splice(_loc7_,1);
|
||||
if(rest)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < rest.length)
|
||||
{
|
||||
_loc5_ = rest[_loc8_];
|
||||
if(_loc5_)
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
_loc5_[(_loc6_[0] as Iitem).defId] = undefined;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_.splice(_loc7_,1);
|
||||
}
|
||||
}
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
_loc7_--;
|
||||
}
|
||||
else if(param1.getIitem(_loc7_).startTime + 10 * _loc4_ >= Utility.getCurrEpochTime())
|
||||
{
|
||||
param1.getIitem(_loc7_).updateValueWithNewStatus(1);
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
|
||||
public static function filterTypedItems(param1:BaseTypedCollection) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc3_:int = 0;
|
||||
if(param1.length == 0 || !param1.getCoreArray()[0].hasOwnProperty("isAvailable"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var _loc2_:int = 86400;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
_loc4_ = param1.getCoreArray()[_loc3_];
|
||||
if(!_loc4_.isAvailable)
|
||||
{
|
||||
param1.getCoreArray().splice(_loc3_,1);
|
||||
_loc3_--;
|
||||
}
|
||||
else if(_loc4_.hasOwnProperty("availabilityStartTime") && _loc4_.hasOwnProperty("updateValueWithNewStatus"))
|
||||
{
|
||||
if(_loc4_.availabilityStartTime + 10 * _loc2_ >= Utility.getCurrEpochTime())
|
||||
{
|
||||
_loc4_.updateValueWithNewStatus(1);
|
||||
}
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleNewData(param1:Array) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
if(param1[0] == "gl")
|
||||
{
|
||||
_loc2_ = int(param1[3]);
|
||||
switch(_loc2_)
|
||||
{
|
||||
case 1000:
|
||||
case 1030:
|
||||
case 1040:
|
||||
case 1051:
|
||||
case 1054:
|
||||
case 1060:
|
||||
handleItemResponse(param1,_loc2_);
|
||||
break;
|
||||
case 1023:
|
||||
handleLocalizationResponse(param1);
|
||||
break;
|
||||
case 1033:
|
||||
case 1062:
|
||||
case 1063:
|
||||
handleMediaResponse(param1);
|
||||
break;
|
||||
case 1035:
|
||||
handleFactResponse(param1);
|
||||
break;
|
||||
case 1037:
|
||||
handleStreamResponse(param1);
|
||||
break;
|
||||
case 1003:
|
||||
handleAvatarResponse(param1);
|
||||
break;
|
||||
case 1049:
|
||||
handleNamebarBadgeResposne(param1);
|
||||
break;
|
||||
case 1052:
|
||||
handleScriptResponse(param1);
|
||||
break;
|
||||
case 1046:
|
||||
handlePetResponse(param1);
|
||||
break;
|
||||
case 1058:
|
||||
handleEBookResponse(param1);
|
||||
break;
|
||||
case 1024:
|
||||
case 1047:
|
||||
case 1065:
|
||||
handleSimpleResponse(param1);
|
||||
break;
|
||||
case 1064:
|
||||
handleInWorldItemsResponse(param1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new Error("GenericListXtCommManager illegal data cmd:" + param1[0]);
|
||||
}
|
||||
|
||||
public static function genericListTypeResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
var _loc5_:Object = null;
|
||||
var _loc2_:Object = param1.def;
|
||||
DefPacksDefHelper.mediaArray[1038] = null;
|
||||
var _loc4_:Object = {};
|
||||
for each(var _loc3_:Object in _loc2_)
|
||||
{
|
||||
_loc5_ = {
|
||||
"defId":int(_loc3_.id),
|
||||
"typeId":int(_loc3_.typeId)
|
||||
};
|
||||
_loc4_[_loc3_.id] = _loc5_;
|
||||
}
|
||||
gMainFrame.userInfo.genericListDefs = _loc4_;
|
||||
}
|
||||
|
||||
private static function handleItemResponse(param1:Array, param2:int) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc7_:Function = null;
|
||||
var _loc3_:int = int(param1[2]);
|
||||
if(_requestCallbackQueue[_loc3_])
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _requestCallbackQueue[_loc3_].length)
|
||||
{
|
||||
_loc5_ = _requestPassbackQueue[_loc3_] ? _requestPassbackQueue[_loc3_][_loc6_] : null;
|
||||
_loc7_ = _requestCallbackQueue[_loc3_][_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc7_(_loc3_,param1,_loc5_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_(_loc3_,param1);
|
||||
}
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
for each(var _loc4_:Object in _requestPassbackQueue)
|
||||
{
|
||||
if(_loc4_ == _loc5_)
|
||||
{
|
||||
delete _requestPassbackQueue[_loc3_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemXtCommManager.shopListResponse(param1,param2);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc3_];
|
||||
delete _requestPassbackQueue[_loc3_];
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemXtCommManager.shopListResponse(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleLocalizationResponse(param1:Array) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc6_:Function = null;
|
||||
var _loc7_:int = 8;
|
||||
var _loc8_:int = int(param1[_loc7_++]);
|
||||
var _loc3_:Array = new Array(_loc8_);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc8_)
|
||||
{
|
||||
_loc3_[_loc5_] = param1[_loc7_++];
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc2_:int = int(param1[2]);
|
||||
if(_requestCallbackQueue[_loc2_])
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _requestCallbackQueue[_loc2_].length)
|
||||
{
|
||||
_loc4_ = _requestPassbackQueue[_loc2_] ? _requestPassbackQueue[_loc2_][_loc5_] : null;
|
||||
_loc6_ = _requestCallbackQueue[_loc2_][_loc5_];
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc6_(_loc2_,_loc3_,_loc4_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_(_loc2_,_loc3_);
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
delete _requestPassbackQueue[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleMediaResponse(param1:Array) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc7_:Function = null;
|
||||
var _loc8_:int = 8;
|
||||
var _loc5_:int = int(param1[_loc8_++]);
|
||||
var _loc9_:Array = new Array(_loc5_);
|
||||
var _loc3_:Array = new Array(_loc5_);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc5_)
|
||||
{
|
||||
_loc9_[_loc6_] = int(param1[_loc8_++]);
|
||||
_loc3_[_loc6_] = param1[_loc8_++];
|
||||
_loc6_++;
|
||||
}
|
||||
var _loc2_:int = int(param1[2]);
|
||||
if(_requestCallbackQueue[_loc2_])
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _requestCallbackQueue[_loc2_].length)
|
||||
{
|
||||
_loc4_ = _requestPassbackQueue[_loc2_] ? _requestPassbackQueue[_loc2_][_loc6_] : null;
|
||||
_loc7_ = _requestCallbackQueue[_loc2_][_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
if(_loc7_.length == 3 || _loc4_ == null)
|
||||
{
|
||||
_loc7_(_loc2_,_loc9_,_loc3_);
|
||||
}
|
||||
else if(_loc7_.length == 4)
|
||||
{
|
||||
_loc7_(_loc2_,_loc9_,_loc3_,_loc4_);
|
||||
}
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
delete _requestPassbackQueue[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleFactResponse(param1:Array) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc5_:Object = null;
|
||||
var _loc7_:Function = null;
|
||||
var _loc8_:int = 8;
|
||||
var _loc3_:int = int(param1[_loc8_++]);
|
||||
var _loc9_:Array = [];
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc3_)
|
||||
{
|
||||
_loc4_ = {
|
||||
"id":int(param1[_loc8_++]),
|
||||
"media":int(param1[_loc8_++]),
|
||||
"title":int(param1[_loc8_++]),
|
||||
"description":int(param1[_loc8_++]),
|
||||
"type":int(param1[_loc8_++]),
|
||||
"userVarId":int(param1[_loc8_++]),
|
||||
"bitIdx":int(param1[_loc8_++])
|
||||
};
|
||||
_loc9_.push(_loc4_);
|
||||
_loc6_++;
|
||||
}
|
||||
var _loc2_:int = int(param1[2]);
|
||||
if(_requestCallbackQueue[_loc2_])
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _requestCallbackQueue[_loc2_].length)
|
||||
{
|
||||
_loc5_ = _requestPassbackQueue[_loc2_] ? _requestPassbackQueue[_loc2_][_loc6_] : null;
|
||||
_loc7_ = _requestCallbackQueue[_loc2_][_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_(_loc9_);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
delete _requestPassbackQueue[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleStreamResponse(param1:Array) : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:int = 8;
|
||||
var _loc3_:String = param1[4];
|
||||
var _loc8_:int = int(param1[_loc5_++]);
|
||||
var _loc6_:StreamDefCollection = new StreamDefCollection();
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc8_)
|
||||
{
|
||||
_loc6_.pushStreamDefItem(new StreamDef(int(param1[_loc5_++]),int(param1[_loc5_++]),param1[_loc5_++],int(param1[_loc5_++]),int(param1[_loc5_++])));
|
||||
_loc4_++;
|
||||
}
|
||||
var _loc2_:int = int(param1[2]);
|
||||
var _loc9_:Object = _streamQueue[_loc2_];
|
||||
if(_loc9_)
|
||||
{
|
||||
if(_loc9_.h)
|
||||
{
|
||||
_loc9_.h.titleTxt = _loc3_;
|
||||
_loc9_.c(_loc2_,_loc6_,_loc9_.h);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_.c(_loc2_,_loc6_);
|
||||
}
|
||||
for each(var _loc7_:Object in _streamQueue)
|
||||
{
|
||||
if(_loc7_ == _streamQueue[_loc2_])
|
||||
{
|
||||
delete _streamQueue[_loc2_];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleAvatarResponse(param1:Array) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc7_:Function = null;
|
||||
var _loc8_:int = 8;
|
||||
var _loc5_:int = int(param1[_loc8_++]);
|
||||
var _loc3_:Array = new Array(_loc5_);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc5_)
|
||||
{
|
||||
_loc3_[_loc6_] = int(param1[_loc8_++]);
|
||||
_loc6_++;
|
||||
}
|
||||
var _loc2_:int = int(param1[2]);
|
||||
if(_requestCallbackQueue[_loc2_])
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _requestCallbackQueue[_loc2_].length)
|
||||
{
|
||||
_loc4_ = _requestPassbackQueue[_loc2_] ? _requestPassbackQueue[_loc2_][_loc6_] : null;
|
||||
_loc7_ = _requestCallbackQueue[_loc2_][_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_(_loc3_);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
delete _requestPassbackQueue[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleNamebarBadgeResposne(param1:Array) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc7_:Function = null;
|
||||
var _loc8_:int = 8;
|
||||
var _loc5_:int = int(param1[_loc8_++]);
|
||||
var _loc2_:Array = new Array(_loc5_);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc5_)
|
||||
{
|
||||
_loc2_[_loc6_] = int(param1[_loc8_++]);
|
||||
_loc6_++;
|
||||
}
|
||||
var _loc3_:int = int(param1[2]);
|
||||
if(_requestCallbackQueue[_loc3_])
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _requestCallbackQueue[_loc3_].length)
|
||||
{
|
||||
_loc4_ = _requestPassbackQueue[_loc3_] ? _requestPassbackQueue[_loc3_][_loc6_] : null;
|
||||
_loc7_ = _requestCallbackQueue[_loc3_][_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_(_loc2_);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc3_];
|
||||
delete _requestPassbackQueue[_loc3_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleScriptResponse(param1:Array) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:Object = null;
|
||||
var _loc6_:Function = null;
|
||||
var _loc7_:int = 8;
|
||||
var _loc8_:int = int(param1[_loc7_++]);
|
||||
var _loc4_:Array = new Array(_loc8_);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc8_)
|
||||
{
|
||||
_loc4_[_loc5_] = int(param1[_loc7_++]);
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc2_:int = int(param1[2]);
|
||||
if(_requestCallbackQueue[_loc2_])
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _requestCallbackQueue[_loc2_].length)
|
||||
{
|
||||
_loc3_ = _requestPassbackQueue[_loc2_] ? _requestPassbackQueue[_loc2_][_loc5_] : null;
|
||||
_loc6_ = _requestCallbackQueue[_loc2_][_loc5_];
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
_loc6_(_loc2_,_loc4_,_loc3_);
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
delete _requestPassbackQueue[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handlePetResponse(param1:Array) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:Object = null;
|
||||
var _loc5_:Function = null;
|
||||
var _loc6_:int = 8;
|
||||
var _loc9_:int = int(param1[_loc6_++]);
|
||||
var _loc7_:Array = [];
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _loc9_)
|
||||
{
|
||||
_loc8_ = int(param1[_loc6_++]);
|
||||
if(param1[_loc6_++] == "1")
|
||||
{
|
||||
_loc7_.push(_loc8_);
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
var _loc2_:int = int(param1[2]);
|
||||
if(_requestCallbackQueue[_loc2_])
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _requestCallbackQueue[_loc2_].length)
|
||||
{
|
||||
_loc3_ = _requestPassbackQueue[_loc2_] ? _requestPassbackQueue[_loc2_][_loc4_] : null;
|
||||
_loc5_ = _requestCallbackQueue[_loc2_][_loc4_];
|
||||
if(_loc5_ != null)
|
||||
{
|
||||
_loc5_(_loc2_,_loc7_,_loc3_);
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
delete _requestPassbackQueue[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleEBookResponse(param1:Array) : void
|
||||
{
|
||||
var _loc7_:int = 0;
|
||||
var _loc5_:Object = null;
|
||||
var _loc8_:Function = null;
|
||||
var _loc2_:int = int(param1[2]);
|
||||
var _loc9_:int = 8;
|
||||
var _loc6_:int = int(param1[_loc9_++]);
|
||||
var _loc10_:Array = new Array(_loc6_);
|
||||
var _loc3_:Array = new Array(_loc6_);
|
||||
var _loc4_:Array = new Array(_loc6_);
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc6_)
|
||||
{
|
||||
_loc10_[_loc7_] = int(param1[_loc9_++]);
|
||||
_loc3_[_loc7_] = int(param1[_loc9_++]);
|
||||
_loc4_[_loc7_] = int(param1[_loc9_++]);
|
||||
_loc7_++;
|
||||
}
|
||||
if(_requestCallbackQueue[_loc2_])
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _requestCallbackQueue[_loc2_].length)
|
||||
{
|
||||
_loc5_ = _requestPassbackQueue[_loc2_] ? _requestPassbackQueue[_loc2_][_loc7_] : null;
|
||||
_loc8_ = _requestCallbackQueue[_loc2_][_loc7_];
|
||||
if(_loc8_ != null)
|
||||
{
|
||||
_loc8_(_loc2_,_loc10_,_loc3_,_loc4_,_loc5_);
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
delete _requestPassbackQueue[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleSimpleResponse(param1:Array) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc4_:Object = null;
|
||||
var _loc7_:Function = null;
|
||||
var _loc2_:int = int(param1[2]);
|
||||
var _loc8_:int = 8;
|
||||
var _loc5_:int = int(param1[_loc8_++]);
|
||||
var _loc3_:Array = new Array(_loc5_);
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _loc5_)
|
||||
{
|
||||
_loc3_[_loc6_] = int(param1[_loc8_++]);
|
||||
_loc6_++;
|
||||
}
|
||||
if(_requestCallbackQueue[_loc2_])
|
||||
{
|
||||
_loc6_ = 0;
|
||||
while(_loc6_ < _requestCallbackQueue[_loc2_].length)
|
||||
{
|
||||
_loc4_ = _requestPassbackQueue[_loc2_] ? _requestPassbackQueue[_loc2_][_loc6_] : null;
|
||||
_loc7_ = _requestCallbackQueue[_loc2_][_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_(_loc2_,_loc3_,_loc4_);
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
delete _requestCallbackQueue[_loc2_];
|
||||
delete _requestPassbackQueue[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleInWorldItemsResponse(param1:Array) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:int = int(param1[2]);
|
||||
var _loc6_:int = 8;
|
||||
var _loc4_:int = int(param1[_loc6_++]);
|
||||
var _loc3_:WorldItemCollection = new WorldItemCollection();
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc4_)
|
||||
{
|
||||
_loc3_.pushWorldDefItem(WorldItemsManager.getWorldItemDef(param1[_loc6_++]));
|
||||
_loc5_++;
|
||||
}
|
||||
filterTypedItems(_loc3_);
|
||||
WorldItemsManager.handleWorldItemsResponse(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.analytics.GATracker;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import flash.desktop.Clipboard;
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.UncaughtErrorEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
|
||||
public class GlobalErrorCatch
|
||||
{
|
||||
|
||||
public function GlobalErrorCatch()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function globalErrorListener(param1:UncaughtErrorEvent) : void
|
||||
{
|
||||
var _loc4_:UncaughtErrorEvent = UncaughtErrorEvent(param1);
|
||||
var _loc2_:Boolean = gMainFrame.clientInfo.accountType == 4 || gMainFrame.clientInfo.extCallsActive;
|
||||
var _loc5_:String = "Default";
|
||||
if(_loc4_)
|
||||
{
|
||||
if(!_loc2_)
|
||||
{
|
||||
_loc4_.preventDefault();
|
||||
}
|
||||
if(_loc4_.error is Error)
|
||||
{
|
||||
_loc5_ = Error(_loc4_.error).message + _loc4_.error.toString() + "\n";
|
||||
_loc5_ = _loc4_.error.getStackTrace();
|
||||
}
|
||||
else if(_loc4_.error is ErrorEvent)
|
||||
{
|
||||
_loc5_ = ErrorEvent(_loc4_.error).text + _loc4_.error.toString();
|
||||
_loc5_ = _loc5_ + "\n This is an ErrorEvent";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = _loc4_.error.toString();
|
||||
_loc5_ = _loc5_ + ("\n This is not an Error or Error event: " + _loc4_.error);
|
||||
}
|
||||
if(_loc2_)
|
||||
{
|
||||
if(ExternalInterface.available)
|
||||
{
|
||||
if(gMainFrame.clientInfo.clientPlatform.toLowerCase() == "electron")
|
||||
{
|
||||
ExternalInterface.call("console.log",_loc5_);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExternalInterface.call("alert",_loc5_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AJClient.globalDebugLog.setVisibility(true);
|
||||
Clipboard.generalClipboard.clear();
|
||||
Clipboard.generalClipboard.setData("air:text",_loc5_);
|
||||
}
|
||||
}
|
||||
}
|
||||
var _loc3_:String = DebugUtility.getTrackedDebugStatements();
|
||||
if(_loc3_.length > 0)
|
||||
{
|
||||
DebugUtility.debugTrace("Tracked Debug Statements:\n" + _loc3_);
|
||||
}
|
||||
DebugUtility.debugTrace(_loc5_,false);
|
||||
GATracker.trackError(_loc5_ + _loc3_,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
[Embed(source="/_assets/1_Load_Screen_swf.bin", mimeType="application/octet-stream")]
|
||||
public class Load_Screen_swf extends ByteArray
|
||||
{
|
||||
|
||||
public function Load_Screen_swf()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import gui.GuiManager;
|
||||
import loadProgress.LoadProgress;
|
||||
import loader.DefPacksDefHelper;
|
||||
import localization.LocalizationManager;
|
||||
import room.RoomXtCommManager;
|
||||
|
||||
public class LocalizationXtCommManager
|
||||
{
|
||||
|
||||
public function LocalizationXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function onLocalizationShardResponse(param1:String) : void
|
||||
{
|
||||
var _loc2_:Array = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:Array = param1.split(",");
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:Array = _loc5_;
|
||||
for each(var _loc3_:String in _loc7_)
|
||||
{
|
||||
_loc2_ = _loc3_.split(":");
|
||||
_loc4_ = int(_loc2_[0]);
|
||||
_loc6_ = int(_loc2_[1]);
|
||||
requestLocalizationPack(_loc6_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function requestLocalizationPack(param1:int) : void
|
||||
{
|
||||
var _loc2_:DefPacksDefHelper = new DefPacksDefHelper();
|
||||
LocalizationManager.currentLanguage = param1;
|
||||
LocalizationManager.hasLocalizations = false;
|
||||
RoomXtCommManager.waitForLangPack = true;
|
||||
AvatarManager.waitForLangPack = true;
|
||||
_loc2_.init(uint("1023" + param1),onLocalizationListResponse,RoomXtCommManager.startRoomLoadIfReady,2);
|
||||
DefPacksDefHelper.mediaArray["1023" + param1] = _loc2_;
|
||||
}
|
||||
|
||||
public static function onLocalizationListResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
DefPacksDefHelper.mediaArray["1023" + LocalizationManager.currentLanguage] = null;
|
||||
LocalizationManager.setLocalizations(param1.def,GuiManager.mainHud != null ? GuiManager.rebuildMainHud : null);
|
||||
LoadProgress.onLocalizationsReceived();
|
||||
if(param1.passback)
|
||||
{
|
||||
param1.passback();
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPreferredLocalizationListResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
DefPacksDefHelper.mediaArray["1055." + LocalizationManager.accountLanguage] = null;
|
||||
LocalizationManager.setPreferredLocalizations(param1.def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,692 @@
|
||||
package
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import avatar.UserInfoCache;
|
||||
import com.sbi.analytics.GATracker;
|
||||
import com.sbi.analytics.SBTracker;
|
||||
import com.sbi.client.SFClient;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.graphics.LayerAnim;
|
||||
import com.sbi.loader.ImageServerURL;
|
||||
import com.sbi.loader.LoaderCache;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Shape;
|
||||
import flash.display.Sprite;
|
||||
import flash.display.Stage;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.KeyboardEvent;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.net.URLLoader;
|
||||
import flash.net.URLRequest;
|
||||
import game.MinigameManager;
|
||||
import gamePlayFlow.GamePlay;
|
||||
import gui.GuiManager;
|
||||
import loadProgress.LoadProgress;
|
||||
import room.LayerManager;
|
||||
import room.RoomManagerWorld;
|
||||
|
||||
public class MainFrame extends Sprite
|
||||
{
|
||||
|
||||
public static const VIEW_WIDTH:int = 900;
|
||||
|
||||
public static const VIEW_HEIGHT:int = 550;
|
||||
|
||||
public static const ROOMS_FOLDER:String = "roomDefs/";
|
||||
|
||||
public static const AUDIO_FOLDER:String = "audio/";
|
||||
|
||||
public static const CDN_SALT:String = "J@mnim4L";
|
||||
|
||||
public static const MSG_ID_LOGIN_IN_USE:int = -11;
|
||||
|
||||
public static const MSG_ID_LOGIN_ACCT_MAINT:int = -12;
|
||||
|
||||
public static const MSG_ID_LOGIN_CONNECTION:int = -14;
|
||||
|
||||
public static const MSG_ID_LOGIN_BANNED:int = -15;
|
||||
|
||||
public static const MSG_ID_LOGIN_SERVER_MAINT:int = -16;
|
||||
|
||||
public static const MSG_ID_LOGIN_CLIENT_MISMATCH:int = -24;
|
||||
|
||||
public static var avatarCreationLogin:MovieClip;
|
||||
|
||||
public static var avatarCreationVO:MovieClip;
|
||||
|
||||
public static var handleLocalExternalCall:Function;
|
||||
|
||||
private static const _configDebugFile:String = "clientdevtest.xml";
|
||||
|
||||
private static const _configDebugTemplateFile:String = "clientdevtest.template.xml";
|
||||
|
||||
private static var _configLoadedCallback:Function;
|
||||
|
||||
private static var m:MainFrame;
|
||||
|
||||
private static var _flashVarUserName:String;
|
||||
|
||||
private static var _client:SFClient = null;
|
||||
|
||||
private static var _path:String = null;
|
||||
|
||||
private static var _stage:Stage;
|
||||
|
||||
private static var _gamePlay:DisplayObjectContainer;
|
||||
|
||||
private static var _waitingRoom:DisplayObjectContainer;
|
||||
|
||||
private static var _createAccount:DisplayObjectContainer;
|
||||
|
||||
private static var _loaderCache:LoaderCache;
|
||||
|
||||
private static var _currStageQuality:String;
|
||||
|
||||
public var userInfo:UserInfoCache;
|
||||
|
||||
public var clientInfo:Object;
|
||||
|
||||
public var classNames:Array;
|
||||
|
||||
private var _layerInfo:Object;
|
||||
|
||||
public function MainFrame()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getInstance(param1:Object = null, param2:Function = null, param3:String = "", param4:DisplayObjectContainer = null) : MainFrame
|
||||
{
|
||||
var _loc7_:Stage = null;
|
||||
var _loc8_:Boolean = false;
|
||||
var _loc5_:Shape = null;
|
||||
var _loc9_:Boolean = false;
|
||||
var _loc6_:URLLoader = null;
|
||||
if(m == null)
|
||||
{
|
||||
if(param3 == null || param4 == null || param4.stage == null)
|
||||
{
|
||||
throw new Error("ERROR: Attempted to call initial getInstance on MainFrame without correct parameters!");
|
||||
}
|
||||
_loc7_ = param4.stage;
|
||||
LoadProgress.init(_loc7_);
|
||||
LoadProgress.show(true,2);
|
||||
LoaderCache.cdnSalt = "J@mnim4L";
|
||||
_loc8_ = ExternalInterface.available;
|
||||
if(_loc8_)
|
||||
{
|
||||
DebugUtility.debugTrace("extIntAvail is true");
|
||||
DebugUtility.debugTrace("mrc dm init starting up call returned:" + ExternalInterface.call("mrc",["dm","init:starting up"]));
|
||||
ExternalInterface.addCallback("handleResize",handleResize);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugUtility.debugTrace("extIntAvail is false");
|
||||
}
|
||||
_loc5_ = new Shape();
|
||||
_loc5_.graphics.clear();
|
||||
_loc5_.graphics.lineStyle(1,16777215);
|
||||
_loc5_.graphics.beginFill(16777215);
|
||||
_loc5_.graphics.drawRect(0,0,900,550);
|
||||
_loc5_.graphics.endFill();
|
||||
param4.addChild(_loc5_);
|
||||
param4.mask = _loc5_;
|
||||
_loc7_.showDefaultContextMenu = false;
|
||||
_loc7_.scaleMode = "showAll";
|
||||
m = new MainFrame();
|
||||
m.init(new Singleton(),param3,_loc7_);
|
||||
gMainFrame = m;
|
||||
_currStageQuality = "medium";
|
||||
_loc7_.addEventListener("keyDown",keyDownListener,false,0,true);
|
||||
_loc7_.addEventListener("rightMouseDown",onRightMouseDown,false,0,true);
|
||||
if(_loc8_)
|
||||
{
|
||||
try
|
||||
{
|
||||
DebugUtility.debugTrace("init:adding mec callback");
|
||||
ExternalInterface.addCallback("mec",handleLocalExternalCall);
|
||||
DebugUtility.debugTrace("init:mec added, calling lc...");
|
||||
ExternalInterface.call("mrc",["lc"]);
|
||||
DebugUtility.debugTrace("init:... lc called, waiting for ixm...");
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
DebugUtility.debugTrace("init:ERROR hit during AJC ext mod setup! msg:" + e.message + " stack:" + e.getStackTrace());
|
||||
}
|
||||
}
|
||||
DebugUtility.debugTrace("init: setting extCallsActive to false");
|
||||
gMainFrame.clientInfo.extCallsActive = false;
|
||||
DebugUtility.debugTrace("init: set extCallsActive to false");
|
||||
_configLoadedCallback = param2;
|
||||
_loc9_ = param1 && param1.smartfoxServer;
|
||||
DebugUtility.debugTrace("MainFrame.getInstance - haveFlashVars:" + _loc9_);
|
||||
gMainFrame.clientInfo.devMode = !_loc9_;
|
||||
if(_loc9_)
|
||||
{
|
||||
if("username" in param1 && param1.username != undefined)
|
||||
{
|
||||
_flashVarUserName = param1.username;
|
||||
}
|
||||
else
|
||||
{
|
||||
_flashVarUserName = "";
|
||||
}
|
||||
DebugUtility.debugTrace("MainFrame.getInstance - flashVars.ingressXt:" + param1.ingressXt + " flashVars.ingressHProxy:" + param1.ingressHProxy + " flashVars.smartfoxServer:" + param1.smartfoxServer + " flashVars.smartfoxPort:" + param1.smartfoxPort + " flashVars.blueboxPort:" + param1.blueboxPort + " flashVars.content:" + param1.content + " flashVars.website:" + param1.website);
|
||||
if(!(param1.smartfoxServer && param1.smartfoxPort && param1.blueboxServer && param1.blueboxPort && param1.content && param1.website))
|
||||
{
|
||||
DebugUtility.debugTrace("MainFrame.getInstance - Invalid FlashVars! Throwing error...");
|
||||
throw new Error("Invalid FlashVars!");
|
||||
}
|
||||
if(!param1.hasOwnProperty("startupRoom"))
|
||||
{
|
||||
param1.startupRoom = "jamaa_township.room_main";
|
||||
}
|
||||
if(!param1.hasOwnProperty("worldmapRoom"))
|
||||
{
|
||||
param1.worldmapRoom = "world_map/room_main.xroom";
|
||||
}
|
||||
if(!param1.hasOwnProperty("dangermapRoom"))
|
||||
{
|
||||
param1.dangermapRoom = "danger_map/room_main.xroom";
|
||||
}
|
||||
if(!param1.hasOwnProperty("clientDebug"))
|
||||
{
|
||||
param1.clientDebug = "false";
|
||||
}
|
||||
if(!param1.hasOwnProperty("forceHttpProxy"))
|
||||
{
|
||||
param1.forceHttpProxy = "false";
|
||||
}
|
||||
if(!param1.hasOwnProperty("build_version"))
|
||||
{
|
||||
param1.build_version = "0";
|
||||
}
|
||||
if(!param1.hasOwnProperty("deploy_version"))
|
||||
{
|
||||
param1.deploy_version = "0";
|
||||
}
|
||||
if(!param1.hasOwnProperty("locale"))
|
||||
{
|
||||
param1.locale = "en-US";
|
||||
}
|
||||
if(!param1.hasOwnProperty("sg_params"))
|
||||
{
|
||||
param1.sg_params = "";
|
||||
}
|
||||
if(!param1.hasOwnProperty("buddyRoomTimerInterval"))
|
||||
{
|
||||
param1.buddyRoomTimerInterval = "30000";
|
||||
}
|
||||
if(!param1.hasOwnProperty("country"))
|
||||
{
|
||||
param1.country = "US";
|
||||
}
|
||||
if(String(param1.sg_params).indexOf("%") >= 0)
|
||||
{
|
||||
throw new Error("Invalid sg_params!");
|
||||
}
|
||||
gMainFrame.clientInfo.localMode = false;
|
||||
LoaderCache.localMode = false;
|
||||
applyConfigVars(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = new URLLoader();
|
||||
_loc6_.dataFormat = "text";
|
||||
_loc6_.addEventListener("complete",configDebugLoadCompleteHandler);
|
||||
_loc6_.addEventListener("ioError",configDebugLoadIOErrorHandler);
|
||||
_loc6_.load(new URLRequest("clientdevtest.xml"));
|
||||
}
|
||||
}
|
||||
GATracker.init();
|
||||
SBTracker.create();
|
||||
return m;
|
||||
}
|
||||
|
||||
public static function isInitialized() : Boolean
|
||||
{
|
||||
return m != null;
|
||||
}
|
||||
|
||||
private static function keyDownListener(param1:KeyboardEvent) : void
|
||||
{
|
||||
var _loc2_:Boolean = false;
|
||||
if(ExternalInterface.available && (param1.keyCode < 37 || param1.keyCode > 40))
|
||||
{
|
||||
ExternalInterface.call("handleKey",{
|
||||
"altKey":param1.altKey,
|
||||
"ctrlKey":param1.ctrlKey,
|
||||
"shiftKey":param1.shiftKey,
|
||||
"keyCode":param1.keyCode
|
||||
});
|
||||
}
|
||||
if(gMainFrame.clientInfo.accountType == 4 || gMainFrame.clientInfo.accountType == 5 || _loc2_)
|
||||
{
|
||||
if(!param1.ctrlKey && param1.shiftKey && !param1.altKey && param1.keyCode == 123)
|
||||
{
|
||||
if(!_client.isConnected || gMainFrame.clientInfo.forceHttpProxy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(_gamePlay)
|
||||
{
|
||||
_gamePlay["reconnecting"] = true;
|
||||
_gamePlay["showLoadProgress"](true,10);
|
||||
}
|
||||
gMainFrame.clientInfo.forceHttpProxy = true;
|
||||
_client.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onRightMouseDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
param1.preventDefault();
|
||||
}
|
||||
|
||||
private static function applyConfigVars(param1:Object) : void
|
||||
{
|
||||
for(var _loc7_:String in param1)
|
||||
{
|
||||
gMainFrame.clientInfo[_loc7_] = param1[_loc7_];
|
||||
}
|
||||
var _loc8_:String = param1.ingressXt;
|
||||
var _loc3_:String = param1.ingressHProxy;
|
||||
var _loc6_:Array = [param1.smartfoxServer];
|
||||
var _loc10_:int = 1;
|
||||
while(param1.hasOwnProperty("smartfoxServer" + _loc10_))
|
||||
{
|
||||
_loc6_.push(param1["smartfoxServer" + _loc10_]);
|
||||
_loc10_++;
|
||||
}
|
||||
gMainFrame.server.setServerConfig(_loc8_,_loc3_,_loc6_,param1.smartfoxPort,param1.blueboxPort,param1.clientDebug);
|
||||
var _loc11_:String = param1.forceHttpProxy;
|
||||
gMainFrame.clientInfo.forceHttpProxy = _loc11_ == "true";
|
||||
var _loc5_:String = "";
|
||||
if(param1.hasOwnProperty("gameSessionId"))
|
||||
{
|
||||
_loc5_ = param1.gameSessionId;
|
||||
if(_loc5_ != null && _loc5_ != "")
|
||||
{
|
||||
gMainFrame.clientInfo.sessionId = int(_loc5_);
|
||||
}
|
||||
}
|
||||
var _loc12_:String = param1.build_version;
|
||||
gMainFrame.clientInfo.buildVersion = _loc12_;
|
||||
LoaderCache.buildVersion = _loc12_;
|
||||
var _loc9_:String = param1.deploy_version;
|
||||
gMainFrame.clientInfo.deployVersion = _loc9_;
|
||||
LoaderCache.deployVersion = _loc9_;
|
||||
var _loc4_:String = param1.locale;
|
||||
gMainFrame.clientInfo.locale = _loc4_;
|
||||
gMainFrame.clientInfo.websiteURL = param1.website;
|
||||
var _loc13_:String = param1.content;
|
||||
if(_loc13_ != null)
|
||||
{
|
||||
while(_loc13_.substring(_loc13_.length - 1) == "/")
|
||||
{
|
||||
_loc13_ = _loc13_.substring(0,_loc13_.length - 1);
|
||||
}
|
||||
_loc13_ += "/";
|
||||
}
|
||||
gMainFrame.clientInfo.contentURL = _loc13_;
|
||||
LoaderCache.contentURL = _loc13_;
|
||||
var _loc14_:Boolean = param1.webRefPath == "create_account";
|
||||
gMainFrame.clientInfo.isCreateAccount = _loc14_;
|
||||
var _loc2_:Boolean = param1.waitingMode == "true";
|
||||
gMainFrame.clientInfo.waitingMode = _loc2_;
|
||||
var _loc15_:int = int(param1.buddyRoomTimerInterval);
|
||||
gMainFrame.clientInfo.buddyRoomTimerInterval = _loc15_;
|
||||
gMainFrame.clientInfo.startUpRoom = String(param1.startupRoom);
|
||||
gMainFrame.clientInfo.worldMapRoom = "roomDefs/" + param1.worldmapRoom;
|
||||
gMainFrame.clientInfo.dangerMapRoom = "roomDefs/" + param1.dangermapRoom;
|
||||
gMainFrame.clientInfo.clientDebug = param1.clientDebug;
|
||||
gMainFrame.clientInfo.sgParams = String(param1.sg_params);
|
||||
gMainFrame.clientInfo.mdUrl = String(param1.mdUrl);
|
||||
gMainFrame.clientInfo.currentTimestamp = Number(param1.currentTimestamp);
|
||||
gMainFrame.clientInfo.sbTrackerIp = String(param1.sbStatTrackerIp);
|
||||
gMainFrame.clientInfo.sbTrackerModulator = param1.sbStatModulator;
|
||||
gMainFrame.clientInfo.authToken = param1.auth_token;
|
||||
gMainFrame.clientInfo.countryCode = param1.country;
|
||||
gMainFrame.clientInfo.playerWallHost = String(param1.playerWallHost);
|
||||
if("redemptionCode" in param1)
|
||||
{
|
||||
gMainFrame.clientInfo.redemptionCode = String(param1.redemptionCode);
|
||||
}
|
||||
gMainFrame.clientInfo.clientPlatform = param1.hasOwnProperty("clientPlatform") ? String(param1.clientPlatform) : Utility.getPlayerType();
|
||||
gMainFrame.clientInfo.clientPlatformVersion = param1.hasOwnProperty("clientPlatformVersion") ? String(param1.clientPlatformVersion) : Utility.getFlashVersion();
|
||||
gMainFrame.clientInfo.refererUuid = "referer_uuid" in param1 ? param1.referer_uuid : "";
|
||||
gMainFrame.clientInfo.selectedAvatarId = "selectedAvatarId" in param1 ? param1.selectedAvatarId : null;
|
||||
gMainFrame.clientInfo.df = "df" in param1 ? param1.df : "";
|
||||
DebugUtility.debugTrace("-configXml/flashVars info-");
|
||||
DebugUtility.debugTrace("ingressXt:" + param1.ingressXt);
|
||||
DebugUtility.debugTrace("ingressHProxy:" + param1.ingressHProxy);
|
||||
DebugUtility.debugTrace("smartfoxServer:" + param1.smartfoxServer);
|
||||
DebugUtility.debugTrace("smartfoxPort:" + param1.smartfoxPort);
|
||||
DebugUtility.debugTrace("blueboxPort:" + param1.blueboxPort);
|
||||
DebugUtility.debugTrace("gameSessionIdStr:" + _loc5_);
|
||||
DebugUtility.debugTrace("buildVersionStr:" + _loc12_);
|
||||
DebugUtility.debugTrace("deployVersionStr:" + _loc9_);
|
||||
DebugUtility.debugTrace("localeStr:" + _loc4_);
|
||||
DebugUtility.debugTrace("contentURL:" + gMainFrame.clientInfo.contentURL);
|
||||
DebugUtility.debugTrace("websiteURL:" + gMainFrame.clientInfo.websiteURL);
|
||||
DebugUtility.debugTrace("isCreateAccount:" + _loc14_ + " webRefPath:" + param1.webRefPath);
|
||||
DebugUtility.debugTrace("isWaitingMode:" + _loc2_ + " cfgVars.waitingMode:" + param1.waitingMode);
|
||||
DebugUtility.debugTrace("startUpRoom:" + gMainFrame.clientInfo.startUpRoom);
|
||||
DebugUtility.debugTrace("worldMapRoom:" + gMainFrame.clientInfo.worldMapRoom);
|
||||
DebugUtility.debugTrace("dangerMapRoom:" + gMainFrame.clientInfo.dangerMapRoom);
|
||||
DebugUtility.debugTrace("clientDebug:" + param1.clientDebug);
|
||||
DebugUtility.debugTrace("forceHttpProxy:" + param1.forceHttpProxy);
|
||||
DebugUtility.debugTrace("sgParams:" + gMainFrame.clientInfo.sgParams);
|
||||
DebugUtility.debugTrace("buddyRoomTimerInterval:" + gMainFrame.clientInfo.buddyRoomTimerInterval);
|
||||
DebugUtility.debugTrace("countryCode:" + gMainFrame.clientInfo.countryCode);
|
||||
DebugUtility.debugTrace("clientPlatform:" + gMainFrame.clientInfo.clientPlatform);
|
||||
DebugUtility.debugTrace("clientPlatformVersion:" + gMainFrame.clientInfo.clientPlatformVersion);
|
||||
_loaderCache = new LoaderCache();
|
||||
if(!gMainFrame.clientInfo.devMode && !gMainFrame.clientInfo.isCreateAccount && (_flashVarUserName == "" || !("auth_token" in param1) || param1.auth_token == null || param1.auth_token == undefined || param1.auth_token == ""))
|
||||
{
|
||||
gMainFrame.clientInfo.failedToInitiate = true;
|
||||
}
|
||||
_configLoadedCallback();
|
||||
}
|
||||
|
||||
private static function configDebugLoadIOErrorHandler(param1:IOErrorEvent) : void
|
||||
{
|
||||
var _loc2_:URLLoader = new URLLoader();
|
||||
_loc2_.dataFormat = "text";
|
||||
_loc2_.addEventListener("complete",configDebugLoadCompleteHandler);
|
||||
_loc2_.addEventListener("ioError",configDebugTemplateLoadIOErrorHandler);
|
||||
_loc2_.load(new URLRequest("clientdevtest.template.xml"));
|
||||
}
|
||||
|
||||
private static function configDebugTemplateLoadIOErrorHandler(param1:IOErrorEvent) : void
|
||||
{
|
||||
throw new Error("IOError reading clientdevtest.xml or clientdevtest.template.xml! ioe:" + param1);
|
||||
}
|
||||
|
||||
private static function configDebugLoadCompleteHandler(param1:Event) : void
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:XML = new XML(param1.target.data);
|
||||
var _loc2_:Object = {};
|
||||
_loc2_["blueboxPort"] = "80";
|
||||
_loc2_["buddyRoomTimerInterval"] = "30000";
|
||||
_loc2_["build_version"] = "0";
|
||||
_loc2_["country"] = "US";
|
||||
_loc2_["deploy_version"] = "0";
|
||||
_loc2_["forceHttpProxy"] = "false";
|
||||
_loc2_["locale"] = "en";
|
||||
_loc2_["sbStatModulator"] = "0";
|
||||
_loc2_["sg_params"] = "";
|
||||
_loc2_["smartfoxPort"] = "443";
|
||||
_loc2_["waitingMode"] = "false";
|
||||
_loc2_["webRefPath"] = "";
|
||||
parseConfigXml(_loc2_,_loc4_);
|
||||
if(_loc4_.hasOwnProperty("envName") && _loc4_.hasOwnProperty("environments"))
|
||||
{
|
||||
_loc3_ = _loc4_.envName.text();
|
||||
if(_loc4_.environments.hasOwnProperty(_loc3_))
|
||||
{
|
||||
DebugUtility.debugTrace("configDebugLoadCompleteHandler: using environment:" + _loc3_);
|
||||
parseConfigXml(_loc2_,_loc4_.environments[_loc3_][0]);
|
||||
}
|
||||
}
|
||||
for(var _loc5_:String in _loc2_)
|
||||
{
|
||||
if(_loc2_[_loc5_] is XMLList && XMLList(_loc2_[_loc5_]).length() > 1)
|
||||
{
|
||||
throw new Error("Invalid clientdevtest xml config! Found multiple tags of same name:" + _loc5_);
|
||||
}
|
||||
}
|
||||
requireConfigKey("content",_loc2_);
|
||||
requireConfigKey("mdUrl",_loc2_);
|
||||
requireConfigKey("playerWallHost",_loc2_);
|
||||
requireConfigKey("website",_loc2_);
|
||||
applyConfigVars(_loc2_);
|
||||
}
|
||||
|
||||
private static function parseConfigXml(param1:Object, param2:XML) : void
|
||||
{
|
||||
var _loc3_:XMLList = null;
|
||||
var _loc5_:int = 0;
|
||||
applyConfigValue("blueboxPort",param1,param2);
|
||||
applyConfigValue("buddyRoomTimerInterval",param1,param2);
|
||||
applyConfigValue("build_version",param1,param2);
|
||||
applyConfigConditionally("clientDebug",param1,param2,"true","false");
|
||||
applyConfigValue("clientPlatform",param1,param2);
|
||||
applyConfigValue("clientPlatformVersion",param1,param2);
|
||||
applyConfigValue("content",param1,param2);
|
||||
applyConfigValue("country",param1,param2);
|
||||
applyConfigValue("dangermapRoom",param1,param2);
|
||||
applyConfigValue("deploy_version",param1,param2);
|
||||
applyConfigValue("df",param1,param2);
|
||||
applyConfigValue("forceHttpProxy",param1,param2);
|
||||
applyConfigValue("ingressHProxy",param1,param2);
|
||||
applyConfigValue("ingressXt",param1,param2);
|
||||
applyConfigValue("locale",param1,param2);
|
||||
applyConfigValue("mdUrl",param1,param2);
|
||||
applyConfigValue("playerWallHost",param1,param2);
|
||||
applyConfigValue("sbStatModulator",param1,param2);
|
||||
applyConfigValue("smartfoxPort",param1,param2);
|
||||
applyConfigValue("smartfoxServer",param1,param2);
|
||||
applyConfigValue("startupRoom",param1,param2);
|
||||
applyConfigValue("waitingMode",param1,param2);
|
||||
applyConfigValue("webRefPath",param1,param2);
|
||||
applyConfigValue("website",param1,param2);
|
||||
applyConfigValue("worldmapRoom",param1,param2);
|
||||
if(param2.hasOwnProperty("autoLogins"))
|
||||
{
|
||||
_loc3_ = param2.autoLogins.children();
|
||||
_loc5_ = 0;
|
||||
for each(var _loc4_:XML in _loc3_)
|
||||
{
|
||||
gMainFrame.clientInfo["autoLogin" + ++_loc5_] = [String(_loc4_.name.text()),String(_loc4_.token.text())];
|
||||
}
|
||||
}
|
||||
if(param2.hasOwnProperty("local"))
|
||||
{
|
||||
if(param2.local.text() == "false")
|
||||
{
|
||||
gMainFrame.clientInfo.localMode = false;
|
||||
LoaderCache.localMode = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.clientInfo.localMode = true;
|
||||
}
|
||||
}
|
||||
var _loc7_:int = 1;
|
||||
while(param2.hasOwnProperty("smartfoxServer" + _loc7_))
|
||||
{
|
||||
param1["smartfoxServer" + _loc7_] = param2["smartfoxServer" + _loc7_].text();
|
||||
_loc7_++;
|
||||
}
|
||||
var _loc6_:int = 1;
|
||||
while(param2.hasOwnProperty("blueboxServer" + _loc6_))
|
||||
{
|
||||
param1["blueboxServer" + _loc6_] = param2["blueboxServer" + _loc6_].text();
|
||||
_loc6_++;
|
||||
}
|
||||
}
|
||||
|
||||
private static function applyConfigValue(param1:String, param2:Object, param3:XML) : void
|
||||
{
|
||||
if(param3.hasOwnProperty(param1))
|
||||
{
|
||||
param2[param1] = param3[param1].text();
|
||||
}
|
||||
}
|
||||
|
||||
private static function applyConfigConditionally(param1:String, param2:Object, param3:XML, param4:String, param5:String) : void
|
||||
{
|
||||
if(param3.hasOwnProperty(param1))
|
||||
{
|
||||
param2[param1] = param3[param1].text();
|
||||
if(param2[param1] != param4)
|
||||
{
|
||||
param2[param1] = param5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function requireConfigKey(param1:String, param2:Object) : void
|
||||
{
|
||||
if(!param2.hasOwnProperty(param1))
|
||||
{
|
||||
throw new Error("Missing required value in clientdevtest xml config! " + param1);
|
||||
}
|
||||
}
|
||||
|
||||
private static function handleResize(param1:int, param2:int) : void
|
||||
{
|
||||
var _loc3_:Number = 100 - Math.min(Math.min(30,(param1 / 900 - 1) * 30),Math.min(30,(param2 / 550 - 1) * 30));
|
||||
if(_stage.contentsScaleFactor > 1)
|
||||
{
|
||||
gMainFrame.currStageQuality = "low";
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.currStageQuality = "medium";
|
||||
}
|
||||
gMainFrame.stage.quality = gMainFrame.currStageQuality;
|
||||
RoomManagerWorld.instance.updateRoomZoom(_loc3_);
|
||||
}
|
||||
|
||||
public function init(param1:Singleton, param2:String, param3:Stage) : void
|
||||
{
|
||||
_path = param2;
|
||||
_stage = param3;
|
||||
_client = new SFClient();
|
||||
userInfo = new UserInfoCache();
|
||||
userInfo.init();
|
||||
clientInfo = {};
|
||||
clientInfo.invisMode = false;
|
||||
classNames = null;
|
||||
}
|
||||
|
||||
public function get server() : SFClient
|
||||
{
|
||||
return _client;
|
||||
}
|
||||
|
||||
public function get path() : String
|
||||
{
|
||||
return _path;
|
||||
}
|
||||
|
||||
override public function get stage() : Stage
|
||||
{
|
||||
return _stage;
|
||||
}
|
||||
|
||||
public function get currStageQuality() : String
|
||||
{
|
||||
return _currStageQuality;
|
||||
}
|
||||
|
||||
public function set currStageQuality(param1:String) : void
|
||||
{
|
||||
_currStageQuality = param1;
|
||||
}
|
||||
|
||||
public function set createAccount(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
_createAccount = param1;
|
||||
}
|
||||
|
||||
public function get createAccount() : DisplayObjectContainer
|
||||
{
|
||||
return _createAccount;
|
||||
}
|
||||
|
||||
public function set waitingRoom(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
_waitingRoom = param1;
|
||||
}
|
||||
|
||||
public function get waitingRoom() : DisplayObjectContainer
|
||||
{
|
||||
return _waitingRoom;
|
||||
}
|
||||
|
||||
public function set gamePlay(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
_gamePlay = param1;
|
||||
}
|
||||
|
||||
public function get gamePlay() : DisplayObjectContainer
|
||||
{
|
||||
return _gamePlay;
|
||||
}
|
||||
|
||||
public function get layerManager() : LayerManager
|
||||
{
|
||||
return (_gamePlay as GamePlay).layerManager;
|
||||
}
|
||||
|
||||
public function get loaderCache() : LoaderCache
|
||||
{
|
||||
return _loaderCache;
|
||||
}
|
||||
|
||||
public function set layerInfo(param1:Object) : void
|
||||
{
|
||||
_layerInfo = param1;
|
||||
ImageServerURL.instance.layerInfo = param1;
|
||||
}
|
||||
|
||||
public function get myFlashVarUserName() : String
|
||||
{
|
||||
return _flashVarUserName;
|
||||
}
|
||||
|
||||
public function set myFlashVarUserName(param1:String) : void
|
||||
{
|
||||
_flashVarUserName = param1;
|
||||
}
|
||||
|
||||
public function isInMinigame() : Boolean
|
||||
{
|
||||
return _gamePlay != null && _gamePlay["isInMinigame"]();
|
||||
}
|
||||
|
||||
public function setAvatarOffsets(param1:Array) : void
|
||||
{
|
||||
LayerAnim.avOffsets = param1;
|
||||
}
|
||||
|
||||
public function switchServersIfNeeded(param1:String) : Boolean
|
||||
{
|
||||
DebugUtility.debugTrace("switchServersIfNeeded called with newNode:" + param1);
|
||||
var _loc2_:String = param1;
|
||||
DebugUtility.debugTrace("checking new node:" + _loc2_ + " vs old node:" + _client.serverIp);
|
||||
if(_client.serverIp == _loc2_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MinigameManager.readySelfForPvpGame(null,"",false);
|
||||
MinigameManager.readySelfForQuickMinigame(null,false);
|
||||
GuiManager.grayOutHudItemsForPrivateLobby(false);
|
||||
GuiManager.closeJoinGamesPopup();
|
||||
AvatarManager.playerCustomPVP = null;
|
||||
_gamePlay["reconnecting"] = true;
|
||||
_gamePlay["showLoadProgress"](true,10);
|
||||
_client.switchServerNode(_loc2_);
|
||||
_client.disconnect();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Singleton
|
||||
{
|
||||
|
||||
public function Singleton()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
package Party
|
||||
{
|
||||
import avatar.Avatar;
|
||||
import avatar.AvatarManager;
|
||||
import avatar.UserInfo;
|
||||
import com.sbi.bit.BitUtility;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import com.sbi.popup.SBStandardPopup;
|
||||
import currency.UserCurrency;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import loadProgress.LoadProgress;
|
||||
import loader.DefPacksDefHelper;
|
||||
import localization.LocalizationManager;
|
||||
import masterpiece.MasterpieceDisplayItem;
|
||||
import pet.PetManager;
|
||||
import room.RoomManagerWorld;
|
||||
import room.RoomXtCommManager;
|
||||
|
||||
public class PartyManager
|
||||
{
|
||||
|
||||
public static const RESTRICTIONS_NONE:int = 0;
|
||||
|
||||
public static const RESTRICTIONS_AVATAR:int = 1;
|
||||
|
||||
public static const RESTRICTIONS_MEMBERONLY:int = 2;
|
||||
|
||||
public static const RESTRICTIONS_PET:int = 4;
|
||||
|
||||
public static const RESTRICTIONS_PET_ONLY:int = 8;
|
||||
|
||||
public static const PARTY_DEF_MASTERPIECE:int = 47;
|
||||
|
||||
private static const PARTY_POPUP_MEDIA_ID:int = 1215;
|
||||
|
||||
private static var _partyDefs:Object;
|
||||
|
||||
private static var _partyPopup:PartyPopup;
|
||||
|
||||
private static var _timeOffset:int;
|
||||
|
||||
private static var _masterpieceDisplayItems:Array;
|
||||
|
||||
public function PartyManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_timeOffset = Math.abs(RoomManagerWorld.instance.shardId) * 10 % 60;
|
||||
requestPartyDefs(null);
|
||||
}
|
||||
|
||||
public static function openPartyPopup() : void
|
||||
{
|
||||
if(_partyPopup)
|
||||
{
|
||||
_partyPopup.destroy();
|
||||
}
|
||||
_partyPopup = new PartyPopup(onPartyPopupClose,_timeOffset);
|
||||
}
|
||||
|
||||
public static function showPartyPopup(param1:Boolean) : void
|
||||
{
|
||||
if(_partyPopup)
|
||||
{
|
||||
_partyPopup.showPopup(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
openPartyPopup();
|
||||
}
|
||||
}
|
||||
|
||||
public static function closePartyPopup(param1:Boolean = false) : void
|
||||
{
|
||||
if(param1 && _partyPopup)
|
||||
{
|
||||
_partyPopup.showPopup(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
onPartyPopupClose();
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateTime(param1:int) : void
|
||||
{
|
||||
if(_partyPopup)
|
||||
{
|
||||
_partyPopup.updateTime(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function get partyDefs() : Object
|
||||
{
|
||||
return _partyDefs;
|
||||
}
|
||||
|
||||
public static function getPartyDef(param1:int) : Object
|
||||
{
|
||||
return _partyDefs[param1];
|
||||
}
|
||||
|
||||
public static function roomSoireeResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:int = 2;
|
||||
if(param1[_loc3_++] == "0")
|
||||
{
|
||||
if(RoomXtCommManager._joiningBuddyCrossNode)
|
||||
{
|
||||
RoomXtCommManager._joiningBuddyCrossNode = false;
|
||||
RoomXtCommManager._loadingNewRoom = false;
|
||||
RoomXtCommManager.sendRoomJoinRequest(gMainFrame.clientInfo.startUpRoom + "#-1");
|
||||
return;
|
||||
}
|
||||
_loc2_ = param1[_loc3_++];
|
||||
RoomXtCommManager.loadingNewRoom = false;
|
||||
if(_loc2_ == "NM")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14779));
|
||||
}
|
||||
else if(_loc2_ == "NA")
|
||||
{
|
||||
GuiManager.showBarrierPopup(0,false,false,param1[_loc3_++]);
|
||||
}
|
||||
else if(_loc2_ == "NP")
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
GuiManager.showBarrierPopup(0,false,false,param1[_loc3_++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function partyListResponse(param1:Object) : void
|
||||
{
|
||||
if(_partyPopup)
|
||||
{
|
||||
_partyPopup.partyListResponse(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function customPartyListResponse(param1:Object) : void
|
||||
{
|
||||
if(_partyPopup)
|
||||
{
|
||||
_partyPopup.customPartyListResponse(param1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function customPartyCreateResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:UserInfo = null;
|
||||
var _loc6_:Boolean = false;
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:int = 2;
|
||||
var _loc3_:Boolean = param1[_loc5_++] == "1";
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc6_ = param1[_loc5_++] == "1";
|
||||
if(_loc6_)
|
||||
{
|
||||
_loc2_ = gMainFrame.userInfo.playerUserInfo;
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.timeLeftHostingCustomParty = int(param1[_loc5_++]);
|
||||
gMainFrame.userInfo.playerUserInfo = _loc2_;
|
||||
AvatarManager.updateCustomPartyHostingDataForMyself();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = gMainFrame.userInfo.playerUserInfo;
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.timeLeftHostingCustomParty = -1;
|
||||
gMainFrame.userInfo.playerUserInfo = _loc2_;
|
||||
AvatarManager.updateCustomPartyHostingDataForMyself();
|
||||
}
|
||||
switch(param1[_loc5_++])
|
||||
{
|
||||
case "ND":
|
||||
_loc4_ = 24247;
|
||||
break;
|
||||
case "EXISTS":
|
||||
_loc4_ = 24249;
|
||||
break;
|
||||
case "NM":
|
||||
_loc4_ = 24236;
|
||||
break;
|
||||
case "INV":
|
||||
case "NR":
|
||||
case "DIS":
|
||||
default:
|
||||
_loc4_ = 24248;
|
||||
}
|
||||
onPartyPopupClose(true);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(_loc4_));
|
||||
}
|
||||
}
|
||||
|
||||
public static function customPartyJoinResponse(param1:Object) : void
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = 2;
|
||||
var _loc2_:Boolean = param1[_loc4_++] == "1";
|
||||
if(!_loc2_)
|
||||
{
|
||||
switch(param1[_loc4_++])
|
||||
{
|
||||
case "NPP":
|
||||
case "BLK":
|
||||
case "DIS":
|
||||
_loc3_ = 24251;
|
||||
break;
|
||||
default:
|
||||
_loc3_ = 24251;
|
||||
}
|
||||
onPartyPopupClose(true);
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(_loc3_));
|
||||
}
|
||||
}
|
||||
|
||||
public static function customPartyIsHostingResponse(param1:Object, param2:String, param3:Function) : void
|
||||
{
|
||||
var _loc5_:UserInfo = null;
|
||||
var _loc4_:int = int(param1[2]);
|
||||
if(param2 != null && param2 != "")
|
||||
{
|
||||
_loc5_ = gMainFrame.userInfo.getUserInfoByUserName(param2);
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc5_.timeLeftHostingCustomParty = _loc4_;
|
||||
}
|
||||
}
|
||||
if(param3 != null)
|
||||
{
|
||||
param3(_loc4_,_loc5_);
|
||||
}
|
||||
}
|
||||
|
||||
public static function customPartyKillResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:UserInfo = gMainFrame.userInfo.playerUserInfo;
|
||||
if(_loc2_)
|
||||
{
|
||||
_loc2_.timeLeftHostingCustomParty = -1;
|
||||
gMainFrame.userInfo.playerUserInfo = _loc2_;
|
||||
AvatarManager.updateCustomPartyHostingDataForMyself();
|
||||
}
|
||||
onPartyPopupClose(true);
|
||||
var _loc3_:int = int(param1[2]);
|
||||
Utility.setupDiamondRefundPopup(GuiManager.guiLayer,_loc3_,null);
|
||||
UserCurrency.setCurrency(UserCurrency.getCurrency(3) + _loc3_,3);
|
||||
}
|
||||
|
||||
public static function requestPartyDefs(param1:Function) : void
|
||||
{
|
||||
var _loc2_:DefPacksDefHelper = new DefPacksDefHelper();
|
||||
_loc2_.init(1047,onPartyDataResponse,param1,2);
|
||||
DefPacksDefHelper.mediaArray[1047] = _loc2_;
|
||||
}
|
||||
|
||||
public static function sendCustomPartyJoin(param1:String, param2:String, param3:String) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
if(param3 == null)
|
||||
{
|
||||
PartyXtCommManager.sendCustomPartyNodeId(param1,param2,onGetPartyNodeId);
|
||||
}
|
||||
else if(param3 == gMainFrame.server.serverIp)
|
||||
{
|
||||
PartyXtCommManager.sendCustomPartyJoinRequest(param2);
|
||||
}
|
||||
else
|
||||
{
|
||||
gMainFrame.clientInfo.autoStartRoom = param2;
|
||||
gMainFrame.clientInfo.autoStartRoomShardId = -4;
|
||||
DebugUtility.debugTrace("using autoStartRoom to prep resend custom party join request after switching server nodes - customPartyCreatorUUID:" + gMainFrame.clientInfo.autoStartRoom + " autoStartRoomShardId:" + gMainFrame.clientInfo.autoStartRoomShardId);
|
||||
if(!gMainFrame.switchServersIfNeeded(param3))
|
||||
{
|
||||
new SBStandardPopup(LoadProgress.loadLayer,LocalizationManager.translateIdOnly(14835),false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function isBeYourPetParty() : Boolean
|
||||
{
|
||||
var _loc1_:Object = null;
|
||||
if(gMainFrame.clientInfo.roomType == 5)
|
||||
{
|
||||
_loc1_ = _partyDefs[gMainFrame.clientInfo.secondaryDefId];
|
||||
if(_loc1_ != null && _loc1_.restrictions == 8)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isPetSpecificRequiredParty() : Boolean
|
||||
{
|
||||
var _loc1_:Object = null;
|
||||
if(gMainFrame.clientInfo.roomType == 5)
|
||||
{
|
||||
_loc1_ = _partyDefs[gMainFrame.clientInfo.secondaryDefId];
|
||||
if(_loc1_ != null && _loc1_.restrictions == 4 && BitUtility.numberOfBitsSet(_loc1_.petDefScalableFlags) == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function canSwitchToAvatar(param1:Avatar, param2:Boolean = false) : Boolean
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
if(gMainFrame.clientInfo.roomType == 5)
|
||||
{
|
||||
_loc3_ = _partyDefs[gMainFrame.clientInfo.secondaryDefId];
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
if(_loc3_.restrictions == 1)
|
||||
{
|
||||
if(BitUtility.bitwiseAnd(_loc3_.avatarDefFlags,BitUtility.leftShiftNumbers(param1.avTypeId - 1)) == 0)
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
GuiManager.showBarrierPopup(0,true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(_loc3_.restrictions == 4 || _loc3_.restrictions == 8)
|
||||
{
|
||||
if(!PetManager.checkIfHasPet(param1.enviroTypeFlag))
|
||||
{
|
||||
if(param2)
|
||||
{
|
||||
GuiManager.showBarrierPopup(0,true,true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function canSwitchPet(param1:Boolean = false) : Boolean
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
if(gMainFrame.clientInfo.roomType == 5)
|
||||
{
|
||||
_loc2_ = _partyDefs[gMainFrame.clientInfo.secondaryDefId];
|
||||
if(_loc2_ != null && (_loc2_.restrictions == 4 || _loc2_.restrictions == 8))
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
GuiManager.showBarrierPopup(0,true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function setupMasterpiecesInRoom(param1:Array) : void
|
||||
{
|
||||
var _loc2_:MasterpieceDisplayItem = null;
|
||||
var _loc6_:Object = null;
|
||||
var _loc5_:int = 0;
|
||||
_masterpieceDisplayItems = [];
|
||||
var _loc3_:Object = gMainFrame.clientInfo.customRoomData;
|
||||
var _loc4_:int = Math.min(12,_loc3_.pool.length);
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < param1.length)
|
||||
{
|
||||
if(_loc5_ < _loc4_)
|
||||
{
|
||||
_loc6_ = _loc3_.pool[_loc5_];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_ = _loc3_.pluspool[_loc5_ - _loc4_];
|
||||
}
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
_loc2_ = new MasterpieceDisplayItem();
|
||||
_loc2_.initFromPool(_loc6_,onMasterpieceDisplayItemLoaded,param1[_loc5_].s.content.imageCont);
|
||||
_masterpieceDisplayItems[_loc2_.uniqueImageId] = _loc2_;
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function handleMasterpieceClick(param1:Object) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
while(param1.parent && param1.parent != _loc2_)
|
||||
{
|
||||
if(param1.parent is MasterpieceDisplayItem)
|
||||
{
|
||||
GuiManager.openMasterpiecePreview((param1.parent as MasterpieceDisplayItem).uniqueImageId,(param1.parent as MasterpieceDisplayItem).uniqueImageCreator,(param1.parent as MasterpieceDisplayItem).uniqueImageCreatorDbId,(param1.parent as MasterpieceDisplayItem).uniqueImageCreatorUUID,(param1.parent as MasterpieceDisplayItem).versionId,null);
|
||||
break;
|
||||
}
|
||||
_loc2_ = param1.parent;
|
||||
param1 = param1.parent;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onMasterpieceDisplayItemLoaded(param1:MasterpieceDisplayItem, param2:Object) : void
|
||||
{
|
||||
var _loc3_:Number = param2.itemLayer.width / param1.width;
|
||||
if(param1.height * _loc3_ > param2.itemLayer.height)
|
||||
{
|
||||
_loc3_ = param2.itemLayer.height / param1.height;
|
||||
}
|
||||
param1.scaleX = param1.scaleY = _loc3_;
|
||||
param2.addChild(param1);
|
||||
delete _masterpieceDisplayItems[param1.uniqueImageId];
|
||||
}
|
||||
|
||||
private static function onPartyDataResponse(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
DefPacksDefHelper.mediaArray[1047] = null;
|
||||
_partyDefs = param1.def;
|
||||
if(param1.passback != null)
|
||||
{
|
||||
param1.passback();
|
||||
}
|
||||
}
|
||||
|
||||
private static function onPartyPopupClose(param1:Boolean = false) : void
|
||||
{
|
||||
if(_partyPopup)
|
||||
{
|
||||
_partyPopup.destroy(param1);
|
||||
_partyPopup = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onGetPartyNodeId(param1:String, param2:Object) : void
|
||||
{
|
||||
if(param2[2] == "1")
|
||||
{
|
||||
sendCustomPartyJoin(param1,param2[3],param2[4]);
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,992 @@
|
||||
package Party
|
||||
{
|
||||
import avatar.AvatarManager;
|
||||
import avatar.UserInfo;
|
||||
import com.greensock.TimelineLite;
|
||||
import com.greensock.TweenLite;
|
||||
import com.greensock.easing.Expo;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import customParty.CustomPartyCreatePopup;
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.text.TextField;
|
||||
import flash.utils.getTimer;
|
||||
import game.MinigameManager;
|
||||
import game.MinigameXtCommManager;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import gui.LoadingSpiral;
|
||||
import gui.WindowAndScrollbarGenerator;
|
||||
import gui.itemWindows.ItemWindowParty;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
import quest.QuestXtCommManager;
|
||||
import room.RoomManagerWorld;
|
||||
import room.RoomXtCommManager;
|
||||
|
||||
public class PartyPopup
|
||||
{
|
||||
|
||||
protected const PARTY_POPUP_MEDIA_ID:int = 1215;
|
||||
|
||||
protected const REQUEST_INTERVAL:Number = 10000;
|
||||
|
||||
protected const ADDITIONAL_ADVENTURE_SCRIPT_ID:int = 283;
|
||||
|
||||
protected var _mediaHelper:MediaHelper;
|
||||
|
||||
protected var _partyPopup:MovieClip;
|
||||
|
||||
protected var _closeCallback:Function;
|
||||
|
||||
protected var _customPartiesLoadingSpiral:LoadingSpiral;
|
||||
|
||||
protected var _ajPartiesLoadingSpiral:LoadingSpiral;
|
||||
|
||||
protected var _ajPartySingleLoadingSpiral:LoadingSpiral;
|
||||
|
||||
protected var _headersLoadingSpiral:LoadingSpiral;
|
||||
|
||||
protected var _partyDefIds:Array;
|
||||
|
||||
protected var _secToStart:Array;
|
||||
|
||||
protected var _additionalScriptDefs:Array;
|
||||
|
||||
protected var _additionalHeaderData:Array;
|
||||
|
||||
protected var _partyMediaIds:Array;
|
||||
|
||||
protected var _secToEnd:Array;
|
||||
|
||||
protected var _partyDefs:Object;
|
||||
|
||||
protected var _mins:Array;
|
||||
|
||||
protected var _hours:Array;
|
||||
|
||||
protected var _customPartyData:Array;
|
||||
|
||||
protected var _adventureHeaderWindow:ItemWindowParty;
|
||||
|
||||
protected var _additionalHeaderWindow1:ItemWindowParty;
|
||||
|
||||
protected var _additionalHeaderWindow2:ItemWindowParty;
|
||||
|
||||
protected var _ajItemWindows:WindowAndScrollbarGenerator;
|
||||
|
||||
protected var _ajItemWindowSingle:ItemWindowParty;
|
||||
|
||||
protected var _customPartyItemWindows:WindowAndScrollbarGenerator;
|
||||
|
||||
protected var _adventureHeaderMediaId:int;
|
||||
|
||||
protected var _timeOffset:int;
|
||||
|
||||
protected var _initialTime:int;
|
||||
|
||||
protected var _numSecPassed:int;
|
||||
|
||||
protected var _hadReceivedPartyList:Boolean;
|
||||
|
||||
protected var _partiesListLoaded:Boolean;
|
||||
|
||||
protected var _useMinimalist:Boolean;
|
||||
|
||||
protected var _tabTimeLine:TimelineLite;
|
||||
|
||||
protected var _customPartyCreatePopup:CustomPartyCreatePopup;
|
||||
|
||||
public function PartyPopup(param1:Function, param2:int)
|
||||
{
|
||||
super();
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_timeOffset = param2;
|
||||
_closeCallback = param1;
|
||||
_useMinimalist = Utility.daysSinceCreated() < 1;
|
||||
_mediaHelper = new MediaHelper();
|
||||
_mediaHelper.init(1215,onPartyPopupLoaded);
|
||||
}
|
||||
|
||||
public function destroy(param1:Boolean = false) : void
|
||||
{
|
||||
_closeCallback = null;
|
||||
_hadReceivedPartyList = false;
|
||||
if(_mediaHelper)
|
||||
{
|
||||
_mediaHelper.destroy();
|
||||
_mediaHelper = null;
|
||||
}
|
||||
if(_adventureHeaderWindow)
|
||||
{
|
||||
_adventureHeaderWindow.destroy();
|
||||
_adventureHeaderWindow = null;
|
||||
}
|
||||
if(_additionalHeaderWindow1)
|
||||
{
|
||||
_additionalHeaderWindow1.destroy();
|
||||
_additionalHeaderWindow1 = null;
|
||||
}
|
||||
if(_additionalHeaderWindow2)
|
||||
{
|
||||
_additionalHeaderWindow2.destroy();
|
||||
_additionalHeaderWindow2 = null;
|
||||
}
|
||||
if(_ajItemWindowSingle)
|
||||
{
|
||||
_ajItemWindowSingle.destroy();
|
||||
_ajItemWindowSingle = null;
|
||||
}
|
||||
if(_ajItemWindows)
|
||||
{
|
||||
_ajItemWindows.destroy();
|
||||
_ajItemWindows = null;
|
||||
}
|
||||
if(_customPartiesLoadingSpiral)
|
||||
{
|
||||
_customPartiesLoadingSpiral.destroy();
|
||||
_customPartiesLoadingSpiral = null;
|
||||
}
|
||||
if(_ajPartiesLoadingSpiral)
|
||||
{
|
||||
_ajPartiesLoadingSpiral.destroy();
|
||||
_ajPartiesLoadingSpiral = null;
|
||||
}
|
||||
if(_ajPartySingleLoadingSpiral)
|
||||
{
|
||||
_ajPartySingleLoadingSpiral.destroy();
|
||||
_ajPartySingleLoadingSpiral = null;
|
||||
}
|
||||
if(_headersLoadingSpiral)
|
||||
{
|
||||
_headersLoadingSpiral.destroy();
|
||||
_headersLoadingSpiral = null;
|
||||
}
|
||||
if(_tabTimeLine)
|
||||
{
|
||||
_tabTimeLine.kill();
|
||||
_tabTimeLine = null;
|
||||
}
|
||||
onCustomPartyCreateClose(param1);
|
||||
DarkenManager.unDarken(_partyPopup.parent);
|
||||
if(GuiManager.guiLayer.contains(_partyPopup.parent))
|
||||
{
|
||||
GuiManager.guiLayer.removeChild(_partyPopup.parent);
|
||||
}
|
||||
_partyPopup = null;
|
||||
}
|
||||
|
||||
public function showPopup(param1:Boolean) : void
|
||||
{
|
||||
if(_partyPopup)
|
||||
{
|
||||
if(_customPartyCreatePopup)
|
||||
{
|
||||
_customPartyCreatePopup.showPopup(false);
|
||||
}
|
||||
_partyPopup.parent.visible = param1;
|
||||
if(param1)
|
||||
{
|
||||
DarkenManager.darken(_partyPopup.parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.unDarken(_partyPopup.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTime(param1:int) : void
|
||||
{
|
||||
if(_hadReceivedPartyList && param1 - _initialTime >= 10000)
|
||||
{
|
||||
_initialTime = param1;
|
||||
onHeartbeat();
|
||||
}
|
||||
}
|
||||
|
||||
public function partyListResponse(param1:Object) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:Array = null;
|
||||
var _loc3_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc2_:int = 0;
|
||||
var _loc9_:Object = null;
|
||||
var _loc4_:String = null;
|
||||
if(_partyPopup)
|
||||
{
|
||||
_partyDefIds = [];
|
||||
_secToStart = [];
|
||||
_secToEnd = [];
|
||||
_partyMediaIds = [];
|
||||
_additionalHeaderData = [];
|
||||
_loc6_ = [];
|
||||
_loc3_ = int(param1[3]);
|
||||
_loc8_ = 4;
|
||||
if(_additionalScriptDefs == null)
|
||||
{
|
||||
GenericListXtCommManager.requestGenericList(283,OnAddionalAdventureScriptDefLoaded,param1);
|
||||
return;
|
||||
}
|
||||
_adventureHeaderMediaId = 2253;
|
||||
_loc2_ = -1;
|
||||
if(_loc2_ != -1)
|
||||
{
|
||||
_additionalHeaderData.push({
|
||||
"isParty":true,
|
||||
"defId":_loc2_,
|
||||
"mediaId":int(_partyDefs[_loc2_].mediaRefId),
|
||||
"secToStart":0,
|
||||
"secToEnd":0,
|
||||
"headerTime":Utility.calculateTime(0)
|
||||
});
|
||||
}
|
||||
if(_additionalScriptDefs.length > 0)
|
||||
{
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _additionalScriptDefs.length)
|
||||
{
|
||||
_loc9_ = QuestXtCommManager.getScriptDef(_additionalScriptDefs[_loc7_]);
|
||||
if(_loc9_)
|
||||
{
|
||||
_additionalHeaderData.push({
|
||||
"isParty":false,
|
||||
"defId":_loc9_.defId,
|
||||
"mediaId":_loc9_.bannerMediaRefId,
|
||||
"secToStart":0,
|
||||
"secToEnd":0,
|
||||
"headerTime":Utility.calculateTime(0)
|
||||
});
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
}
|
||||
initializePartyPopup();
|
||||
_loc4_ = _useMinimalist ? "Sml" : "";
|
||||
switch(int(_additionalHeaderData.length))
|
||||
{
|
||||
case 0:
|
||||
_partyPopup.gotoAndStop("header" + _loc4_);
|
||||
break;
|
||||
case 1:
|
||||
_partyPopup.gotoAndStop("twoHeader" + _loc4_);
|
||||
break;
|
||||
default:
|
||||
_partyPopup.gotoAndStop("threeHeader" + _loc4_);
|
||||
}
|
||||
setupCreateJoinButtonText();
|
||||
addEventListeners();
|
||||
setupLoadingSpirals();
|
||||
buildHeaderPartyWindows();
|
||||
_loc7_ = 0;
|
||||
while(_loc7_ < _loc3_)
|
||||
{
|
||||
_partyDefIds[_loc7_] = int(param1[_loc8_]);
|
||||
if(_partyDefs[int(param1[_loc8_])])
|
||||
{
|
||||
_loc5_ = int(_partyDefs[int(param1[_loc8_])].titleStrId);
|
||||
if(!_loc6_[_loc5_])
|
||||
{
|
||||
_loc6_[_loc5_] = true;
|
||||
}
|
||||
_partyMediaIds[_loc7_] = int(_partyDefs[int(param1[_loc8_++])].mediaRefId);
|
||||
_secToStart[_loc7_] = Number(param1[_loc8_++]);
|
||||
if(_secToStart[_loc7_] != 0)
|
||||
{
|
||||
var _loc10_:int = _loc7_;
|
||||
var _loc11_:Number = _secToStart[_loc10_] + _timeOffset;
|
||||
_secToStart[_loc10_] = _loc11_;
|
||||
}
|
||||
_secToEnd[_loc7_] = Number(param1[_loc8_++]);
|
||||
}
|
||||
_loc7_++;
|
||||
}
|
||||
_loc6_ = null;
|
||||
calculateTime();
|
||||
_initialTime = getTimer();
|
||||
buildAJSinglePartyWindow();
|
||||
_hadReceivedPartyList = true;
|
||||
if(!_useMinimalist)
|
||||
{
|
||||
PartyXtCommManager.sendCustomPartyListRequest(0,200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function customPartyListResponse(param1:Object) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc6_:int = 0;
|
||||
var _loc10_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:Object = null;
|
||||
var _loc4_:Array = null;
|
||||
_customPartyData = [];
|
||||
var _loc9_:int = 2;
|
||||
var _loc5_:Boolean = param1[_loc9_++] == "1";
|
||||
var _loc3_:int = int(param1[_loc9_++]);
|
||||
if(_loc3_ > 0)
|
||||
{
|
||||
_loc2_ = int(param1[_loc9_++]);
|
||||
_loc6_ = int(param1[_loc9_++]);
|
||||
_loc10_ = int(param1[_loc9_++]);
|
||||
if(_loc10_ > 0)
|
||||
{
|
||||
_loc8_ = 0;
|
||||
while(_loc8_ < _loc10_)
|
||||
{
|
||||
_loc7_ = {
|
||||
"creator":param1[_loc9_++],
|
||||
"name":param1[_loc9_++],
|
||||
"nodeId":param1[_loc9_++],
|
||||
"defId":int(param1[_loc9_++]),
|
||||
"timeLeft":Number(param1[_loc9_++])
|
||||
};
|
||||
_loc4_ = _loc7_.name.split("|");
|
||||
_loc7_.name = LocalizationManager.translateIdOnly(_loc4_[0]) + " " + LocalizationManager.translateIdOnly(_loc4_[1]) + " " + LocalizationManager.translateIdOnly(_loc4_[2]);
|
||||
_customPartyData.push(_loc7_);
|
||||
_loc8_++;
|
||||
}
|
||||
}
|
||||
}
|
||||
buildCustomPartyWindows();
|
||||
}
|
||||
|
||||
private function onPartyPopupLoaded(param1:MovieClip) : void
|
||||
{
|
||||
_partyPopup = (param1.getChildAt(0) as MovieClip).partyFrames;
|
||||
_mins = [];
|
||||
_hours = [];
|
||||
requestData();
|
||||
}
|
||||
|
||||
protected function initializePartyPopup() : void
|
||||
{
|
||||
if(!GuiManager.guiLayer.contains(_partyPopup.parent))
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
_partyPopup.parent.x = 900 * 0.5;
|
||||
_partyPopup.parent.y = 550 * 0.5;
|
||||
GuiManager.guiLayer.addChild(_partyPopup.parent);
|
||||
DarkenManager.darken(_partyPopup.parent);
|
||||
}
|
||||
}
|
||||
|
||||
protected function requestData() : void
|
||||
{
|
||||
if(PartyManager.partyDefs != null)
|
||||
{
|
||||
_partyDefs = PartyManager.partyDefs;
|
||||
PartyXtCommManager.sendPartyListRequest();
|
||||
}
|
||||
else
|
||||
{
|
||||
PartyManager.requestPartyDefs(requestData);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setupLoadingSpirals() : void
|
||||
{
|
||||
if(_partyPopup.itemWindowSpiral)
|
||||
{
|
||||
_headersLoadingSpiral = new LoadingSpiral(_partyPopup.itemWindowSpiral,_partyPopup.itemWindowSpiral.width * 0.5,_partyPopup.itemWindowSpiral.height * 0.5);
|
||||
}
|
||||
if(!_useMinimalist)
|
||||
{
|
||||
_customPartiesLoadingSpiral = new LoadingSpiral(_partyPopup.itemWindow,_partyPopup.itemWindow.width * 0.5,_partyPopup.itemWindow.height * 0.5);
|
||||
_ajPartiesLoadingSpiral = new LoadingSpiral(_partyPopup.frameDrawerCont.itemWindow,_partyPopup.frameDrawerCont.itemWindow.width * 0.5,_partyPopup.frameDrawerCont.itemWindow.height * 0.5);
|
||||
}
|
||||
_ajPartySingleLoadingSpiral = new LoadingSpiral(_partyPopup.itemWindowAJ,_partyPopup.itemWindowAJ.width * 0.5,_partyPopup.itemWindowAJ.height * 0.5);
|
||||
}
|
||||
|
||||
protected function buildAJSinglePartyWindow() : void
|
||||
{
|
||||
if(_ajItemWindowSingle)
|
||||
{
|
||||
_ajItemWindowSingle.destroy();
|
||||
}
|
||||
_ajItemWindowSingle = new ItemWindowParty(onSinglePartyWindowLoaded,_partyDefIds[0],"",0,ajWinMouseDown,null,null,null,{
|
||||
"mediaRefId":_partyMediaIds,
|
||||
"printTimeFunc":getAJWindowPrintTime
|
||||
});
|
||||
}
|
||||
|
||||
private function buildAJPartyWindows() : void
|
||||
{
|
||||
if(_ajItemWindows)
|
||||
{
|
||||
_ajItemWindows.destroy();
|
||||
}
|
||||
_ajItemWindows = new WindowAndScrollbarGenerator();
|
||||
_ajItemWindows.init(_partyPopup.frameDrawerCont.itemWindow.width,_partyPopup.frameDrawerCont.itemWindow.height,3,0,1,6,0,0,2,0,1,ItemWindowParty,_partyDefIds,"",0,{"mouseDown":ajWinMouseDown},{
|
||||
"mediaRefId":_partyMediaIds,
|
||||
"printTimeFunc":getAJWindowPrintTime
|
||||
},onAjPartiesLoaded,true,false,false);
|
||||
}
|
||||
|
||||
private function buildCustomPartyWindows() : void
|
||||
{
|
||||
if(_customPartyItemWindows)
|
||||
{
|
||||
_customPartyItemWindows.destroy();
|
||||
}
|
||||
_customPartyItemWindows = new WindowAndScrollbarGenerator();
|
||||
_customPartyItemWindows.init(_partyPopup.itemWindow.width,_partyPopup.itemWindow.height,4,0,1,4,0,0,2,0,1,ItemWindowParty,_customPartyData,"",0,{"mouseDown":customWinMouseDown},{"printTimeFunc":getCustomWindowPrintTime},onCustomPartiesLoaded,true,false,false);
|
||||
}
|
||||
|
||||
protected function buildHeaderPartyWindows() : void
|
||||
{
|
||||
if(_adventureHeaderWindow)
|
||||
{
|
||||
_adventureHeaderWindow.destroy();
|
||||
_adventureHeaderWindow = null;
|
||||
}
|
||||
_adventureHeaderWindow = new ItemWindowParty(onSinglePartyWindowLoaded,null,"",0,singleWinMouseDown,null,null,null,{"mediaRefId":[_adventureHeaderMediaId]});
|
||||
if(_additionalHeaderData.length > 0)
|
||||
{
|
||||
if(_additionalHeaderWindow1)
|
||||
{
|
||||
_additionalHeaderWindow1.destroy();
|
||||
_additionalHeaderWindow1 = null;
|
||||
}
|
||||
_additionalHeaderWindow1 = new ItemWindowParty(onSinglePartyWindowLoaded,null,"",0,singleWinMouseDown,null,null,null,{
|
||||
"mediaRefId":[_additionalHeaderData[0].mediaId],
|
||||
"additionalIndex":0
|
||||
});
|
||||
if(_additionalHeaderData.length == 2)
|
||||
{
|
||||
if(_additionalHeaderWindow2)
|
||||
{
|
||||
_additionalHeaderWindow2.destroy();
|
||||
_additionalHeaderWindow2 = null;
|
||||
}
|
||||
_additionalHeaderWindow2 = new ItemWindowParty(onSinglePartyWindowLoaded,null,"",0,singleWinMouseDown,null,null,null,{
|
||||
"mediaRefId":[_additionalHeaderData[1].mediaId],
|
||||
"additionalIndex":1
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function calculatePrintTime(param1:int, param2:Boolean = false) : String
|
||||
{
|
||||
return Utility.calculatePrintTime(_mins[param1],_hours[param1],param2);
|
||||
}
|
||||
|
||||
protected function calculateTime() : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
var _loc1_:int = 0;
|
||||
_loc1_ = 0;
|
||||
while(_loc1_ < _secToStart.length)
|
||||
{
|
||||
_loc2_ = Utility.calculateTime(_secToStart[_loc1_]);
|
||||
_mins[_loc1_] = _loc2_.mins;
|
||||
_hours[_loc1_] = _loc2_.hours;
|
||||
_loc1_++;
|
||||
}
|
||||
}
|
||||
|
||||
private function rebuildList() : void
|
||||
{
|
||||
var _loc1_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc2_:Array = [];
|
||||
_partyMediaIds = [];
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _partyDefIds.length)
|
||||
{
|
||||
_loc1_ = int(_partyDefs[_partyDefIds[_loc3_]].titleStrId);
|
||||
if(!_loc2_[_loc1_])
|
||||
{
|
||||
_loc2_[_loc1_] = true;
|
||||
}
|
||||
_partyMediaIds[_loc3_] = int(_partyDefs[_partyDefIds[_loc3_]].mediaRefId);
|
||||
_loc3_++;
|
||||
}
|
||||
if(!_useMinimalist)
|
||||
{
|
||||
buildAJPartyWindows();
|
||||
}
|
||||
}
|
||||
|
||||
private function getAJWindowPrintTime(param1:int) : String
|
||||
{
|
||||
return _secToStart[param1] > 0 ? calculatePrintTime(param1) : "";
|
||||
}
|
||||
|
||||
private function getCustomWindowPrintTime(param1:int) : String
|
||||
{
|
||||
return Utility.calculatePrintTimeForCustomParties(param1);
|
||||
}
|
||||
|
||||
protected function addEventListeners() : void
|
||||
{
|
||||
_partyPopup.addEventListener("mouseDown",onPopup,false,0,true);
|
||||
_partyPopup.bx.addEventListener("mouseDown",onCloseBtn,false,0,true);
|
||||
if(!_useMinimalist)
|
||||
{
|
||||
_partyPopup.frameDrawerCont.ajhqPartyTab_btn.addEventListener("mouseDown",onOpenPartyTab,false,0,true);
|
||||
_partyPopup.frameDrawerCont.backTab_btn.addEventListener("mouseDown",onClosePartyTab,false,0,true);
|
||||
_partyPopup.throwParty_btn.addEventListener("mouseDown",onThrowPartyBtn,false,0,true);
|
||||
_partyPopup.goToParty_btn.addEventListener("mouseDown",onHostPartyBtn,false,0,true);
|
||||
}
|
||||
}
|
||||
|
||||
protected function removeEventListeners() : void
|
||||
{
|
||||
_partyPopup.removeEventListener("mouseDown",onPopup);
|
||||
_partyPopup.bx.removeEventListener("mouseDown",onCloseBtn);
|
||||
if(!_useMinimalist)
|
||||
{
|
||||
_partyPopup.frameDrawerCont.ajhqPartyTab_btn.removeEventListener("mouseDown",onOpenPartyTab);
|
||||
_partyPopup.frameDrawerCont.backTab_btn.removeEventListener("mouseDown",onClosePartyTab);
|
||||
_partyPopup.throwParty_btn.removeEventListener("mouseDown",onThrowPartyBtn);
|
||||
_partyPopup.goToParty_btn.removeEventListener("mouseDown",onHostPartyBtn);
|
||||
}
|
||||
}
|
||||
|
||||
protected function setupCreateJoinButtonText() : void
|
||||
{
|
||||
var _loc1_:UserInfo = null;
|
||||
var _loc2_:int = 0;
|
||||
if(!_useMinimalist)
|
||||
{
|
||||
_loc1_ = gMainFrame.userInfo.playerUserInfo;
|
||||
if(_loc1_)
|
||||
{
|
||||
if(_loc1_.isStillHosting)
|
||||
{
|
||||
_partyPopup.goToParty_btn.visible = true;
|
||||
_partyPopup.throwParty_btn.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_partyPopup.goToParty_btn.visible = false;
|
||||
_partyPopup.throwParty_btn.visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function OnAddionalAdventureScriptDefLoaded(param1:int, param2:Array, param3:Object) : void
|
||||
{
|
||||
_additionalScriptDefs = param2;
|
||||
partyListResponse(param3);
|
||||
}
|
||||
|
||||
private function onSinglePartyWindowLoaded(param1:ItemWindowParty, param2:int = -1) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
if(param1 == _adventureHeaderWindow)
|
||||
{
|
||||
param1.setupTextAndAnims("");
|
||||
_partyPopup.itemWindowHeader.addChild(param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(param1 == _ajItemWindowSingle)
|
||||
{
|
||||
_ajPartySingleLoadingSpiral.visible = false;
|
||||
(_ajItemWindowSingle.txt.timeTxt as TextField).gridFitType = "subpixel";
|
||||
(_ajItemWindowSingle.txt.titleTxtCont.titleTxt as TextField).gridFitType = "subpixel";
|
||||
_partyPopup.itemWindowAJ.addChild(param1);
|
||||
return;
|
||||
}
|
||||
_loc3_ = param1 == _additionalHeaderWindow1 ? _additionalHeaderData[0] : _additionalHeaderData[1];
|
||||
param1.defId = _loc3_.defId;
|
||||
param1.setupTextAndAnims(_loc3_.secToStart > 0 ? Utility.calculatePrintTime(_loc3_.headerTime.mins,_loc3_.headerTime.hours) : "");
|
||||
if(_loc3_.isParty)
|
||||
{
|
||||
param1.titleText = _partyDefs[_loc3_.defId].titleStrId;
|
||||
}
|
||||
if(param1 == _additionalHeaderWindow1)
|
||||
{
|
||||
_partyPopup.itemWindowHeader2.addChild(param1);
|
||||
}
|
||||
else if(param1 == _additionalHeaderWindow2)
|
||||
{
|
||||
_partyPopup.itemWindowHeader3.addChild(param1);
|
||||
}
|
||||
}
|
||||
if(_additionalHeaderData.length == 2)
|
||||
{
|
||||
if(_additionalHeaderWindow2 && _additionalHeaderWindow2.parent != null && _additionalHeaderWindow1.parent != null && _adventureHeaderWindow.parent != null)
|
||||
{
|
||||
_headersLoadingSpiral.visible = false;
|
||||
}
|
||||
}
|
||||
else if(_additionalHeaderWindow1 && _additionalHeaderWindow1.parent != null && _adventureHeaderWindow.parent != null)
|
||||
{
|
||||
_headersLoadingSpiral.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function onAjPartiesLoaded() : void
|
||||
{
|
||||
_ajPartiesLoadingSpiral.visible = false;
|
||||
_partyPopup.frameDrawerCont.itemWindow.addChild(_ajItemWindows);
|
||||
_partiesListLoaded = true;
|
||||
}
|
||||
|
||||
private function onCustomPartiesLoaded() : void
|
||||
{
|
||||
_customPartiesLoadingSpiral.visible = false;
|
||||
_partyPopup.itemWindow.addChild(_customPartyItemWindows);
|
||||
}
|
||||
|
||||
protected function onMinigameInfoResponse() : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
MinigameManager.handleGameClick({"typeDefId":102},null,true);
|
||||
}
|
||||
|
||||
private function onHeartbeat() : void
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
var _loc1_:int = 0;
|
||||
var _loc2_:ItemWindowParty = null;
|
||||
var _loc6_:int = 0;
|
||||
var _loc5_:int = 10;
|
||||
_numSecPassed += _loc5_;
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _secToStart.length)
|
||||
{
|
||||
_loc3_ = int(_hours[_loc4_]);
|
||||
_loc1_ = int(_mins[_loc4_]);
|
||||
if(_loc3_ > 0 || _loc1_ > 0)
|
||||
{
|
||||
var _loc7_:* = _loc4_;
|
||||
var _loc8_:* = _secToStart[_loc7_] - _loc5_;
|
||||
_secToStart[_loc7_] = _loc8_;
|
||||
if(_secToStart[_loc4_] <= 0)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
_loc1_ = 0;
|
||||
}
|
||||
else if(_numSecPassed == 60)
|
||||
{
|
||||
if(_loc3_ > 0 && _loc1_ == 0)
|
||||
{
|
||||
_loc3_--;
|
||||
}
|
||||
if(_loc1_ == 0)
|
||||
{
|
||||
_loc1_ = 59;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_--;
|
||||
}
|
||||
}
|
||||
_hours[_loc4_] = _loc3_;
|
||||
_mins[_loc4_] = _loc1_;
|
||||
if(_partiesListLoaded)
|
||||
{
|
||||
_loc2_ = ItemWindowParty(_ajItemWindows.mediaWindows[_loc4_]);
|
||||
_loc2_.setupTextAndAnims(_loc3_ > 0 || _loc1_ > 0 ? calculatePrintTime(_loc4_) : "");
|
||||
}
|
||||
if(_loc4_ == 0)
|
||||
{
|
||||
_ajItemWindowSingle.setupTextAndAnims(_loc3_ > 0 || _loc1_ > 0 ? calculatePrintTime(_loc4_) : "");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc8_ = _loc4_;
|
||||
_loc7_ = _secToEnd[_loc8_] - _loc5_;
|
||||
_secToEnd[_loc8_] = _loc7_;
|
||||
if(_secToEnd[_loc4_] <= 0)
|
||||
{
|
||||
if(_partiesListLoaded)
|
||||
{
|
||||
_ajItemWindows.deleteItem(_loc4_,_partyDefIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
_partyDefIds.splice(_loc4_,1);
|
||||
}
|
||||
_partyMediaIds.splice(_loc4_,1);
|
||||
_secToStart.splice(_loc4_,1);
|
||||
_secToEnd.splice(_loc4_,1);
|
||||
_hours.splice(_loc4_,1);
|
||||
_mins.splice(_loc4_,1);
|
||||
if(_loc4_ == 0)
|
||||
{
|
||||
_ajItemWindowSingle.destroy();
|
||||
_ajItemWindowSingle = new ItemWindowParty(onSinglePartyWindowLoaded,null,"",0,ajWinMouseDown,null,null,null,{
|
||||
"mediaRefId":_partyMediaIds,
|
||||
"printTimeFunc":getAJWindowPrintTime
|
||||
});
|
||||
}
|
||||
_loc4_--;
|
||||
}
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
if(_customPartyData)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < _customPartyData.length)
|
||||
{
|
||||
_customPartyData[_loc4_].timeLeft -= _loc5_;
|
||||
_loc6_ = int(_customPartyData[_loc4_].timeLeft);
|
||||
if(_loc6_ <= 0)
|
||||
{
|
||||
_customPartyItemWindows.deleteItem(_loc4_,_customPartyData);
|
||||
setupCreateJoinButtonText();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = ItemWindowParty(_customPartyItemWindows.mediaWindows[_loc4_]);
|
||||
_loc2_.setupTextAndAnims(getCustomWindowPrintTime(_loc6_));
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
if(_numSecPassed == 60)
|
||||
{
|
||||
_numSecPassed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private function onCustomPartyCreateClose(param1:Boolean = false) : void
|
||||
{
|
||||
if(_customPartyCreatePopup)
|
||||
{
|
||||
_customPartyCreatePopup.destroy(param1);
|
||||
_customPartyCreatePopup = null;
|
||||
}
|
||||
}
|
||||
|
||||
private function onPopup(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
|
||||
protected function onCloseBtn(param1:MouseEvent) : void
|
||||
{
|
||||
if(param1)
|
||||
{
|
||||
param1.stopPropagation();
|
||||
}
|
||||
if(_closeCallback != null)
|
||||
{
|
||||
_closeCallback();
|
||||
}
|
||||
else
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private function onOpenPartyTab(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(_tabTimeLine)
|
||||
{
|
||||
if(_tabTimeLine.reversed())
|
||||
{
|
||||
_tabTimeLine.reversed(false);
|
||||
_tabTimeLine.resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
_tabTimeLine.reversed(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_tabTimeLine = new TimelineLite();
|
||||
_tabTimeLine.add(new TweenLite(_partyPopup.frameDrawerCont,1,{
|
||||
"x":"+=370",
|
||||
"ease":Expo.easeInOut
|
||||
}),0);
|
||||
_tabTimeLine.add(new TweenLite(_partyPopup,1,{
|
||||
"x":"-=170",
|
||||
"ease":Expo.easeInOut
|
||||
}),0);
|
||||
}
|
||||
if(_ajItemWindows == null && !_useMinimalist)
|
||||
{
|
||||
buildAJPartyWindows();
|
||||
}
|
||||
}
|
||||
|
||||
private function onClosePartyTab(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(!_tabTimeLine.reversed())
|
||||
{
|
||||
_tabTimeLine.reverse();
|
||||
}
|
||||
}
|
||||
|
||||
private function onThrowPartyBtn(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
if(_customPartyCreatePopup)
|
||||
{
|
||||
_customPartyCreatePopup.destroy();
|
||||
}
|
||||
_customPartyCreatePopup = new CustomPartyCreatePopup(onCustomPartyCreateClose);
|
||||
}
|
||||
|
||||
private function onHostPartyBtn(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:UserInfo = gMainFrame.userInfo.playerUserInfo;
|
||||
if(_loc3_)
|
||||
{
|
||||
if(_loc3_.isStillHosting)
|
||||
{
|
||||
_loc2_ = gMainFrame.server.getCurrentRoomName();
|
||||
if(_loc2_.indexOf("pparty") == -1 || _loc2_.indexOf(_loc3_.userName) == -1)
|
||||
{
|
||||
PartyManager.sendCustomPartyJoin(_loc3_.userName,_loc3_.uuid,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function singleWinMouseDown(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc2_:Object = null;
|
||||
param1.stopPropagation();
|
||||
if(param1.currentTarget == _adventureHeaderWindow)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
if(AvatarManager.roomEnviroType == 1)
|
||||
{
|
||||
RoomXtCommManager.sendNonDenRoomJoinRequest("adventures.queststaging_421_0_586#" + RoomManagerWorld.instance.shardId);
|
||||
}
|
||||
else
|
||||
{
|
||||
RoomXtCommManager.sendNonDenRoomJoinRequest("adventures.queststaging_421_0_585#" + RoomManagerWorld.instance.shardId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = _additionalHeaderData[param1.currentTarget.additionalIndex];
|
||||
if(_loc2_)
|
||||
{
|
||||
if(_loc2_.isParty)
|
||||
{
|
||||
if(_loc2_.secToStart <= 0)
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
PartyXtCommManager.sendJoinPartyRequest(param1.currentTarget.defId);
|
||||
onCloseBtn(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14778,Utility.calculatePrintTime(_loc2_.headerTime.mins,_loc2_.headerTime.hours,true)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
QuestXtCommManager.sendQuestCreateJoinPublic(param1.currentTarget.defId);
|
||||
onCloseBtn(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function ajWinMouseDown(param1:MouseEvent) : void
|
||||
{
|
||||
param1.stopPropagation();
|
||||
var _loc2_:int = int(param1.currentTarget.index);
|
||||
if(_secToStart[_loc2_] - _timeOffset <= 0)
|
||||
{
|
||||
if(_secToEnd[_loc2_] <= (getTimer() - _initialTime) / 1000)
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14777));
|
||||
if(_partiesListLoaded)
|
||||
{
|
||||
_ajItemWindows.deleteItem(_loc2_,_partyDefIds);
|
||||
}
|
||||
else
|
||||
{
|
||||
_partyDefIds.splice(_loc2_,1);
|
||||
}
|
||||
_partyMediaIds.splice(_loc2_,1);
|
||||
_secToStart.splice(_loc2_,1);
|
||||
_secToEnd.splice(_loc2_,1);
|
||||
_hours.splice(_loc2_,1);
|
||||
_mins.splice(_loc2_,1);
|
||||
if(_loc2_ == 0)
|
||||
{
|
||||
_ajItemWindowSingle.destroy();
|
||||
_ajItemWindowSingle = new ItemWindowParty(onSinglePartyWindowLoaded,null,"",0,ajWinMouseDown,null,null,null,{
|
||||
"mediaRefId":_partyMediaIds,
|
||||
"printTimeFunc":getAJWindowPrintTime
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
if(param1.currentTarget.isGame)
|
||||
{
|
||||
if(MinigameManager.minigameInfoCache.getMinigameInfo(102) == null)
|
||||
{
|
||||
MinigameXtCommManager.sendMinigameInfoRequest([102],false,onMinigameInfoResponse);
|
||||
}
|
||||
else
|
||||
{
|
||||
MinigameManager.handleGameClick({"typeDefId":102},null,true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PartyXtCommManager.sendJoinPartyRequest(param1.currentTarget.defId);
|
||||
}
|
||||
onCloseBtn(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdAndInsertOnly(14778,calculatePrintTime(_loc2_,true)));
|
||||
}
|
||||
}
|
||||
|
||||
private function customWinMouseDown(param1:MouseEvent) : void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc5_:Object = null;
|
||||
var _loc3_:UserInfo = null;
|
||||
param1.stopPropagation();
|
||||
var _loc4_:int = int(param1.currentTarget.index);
|
||||
if(param1.currentTarget.timeLeft <= 0)
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(14777));
|
||||
if(_customPartyItemWindows)
|
||||
{
|
||||
_customPartyItemWindows.deleteItem(_loc4_,_customPartyData);
|
||||
}
|
||||
else
|
||||
{
|
||||
_customPartyData.splice(_loc4_,1);
|
||||
}
|
||||
setupCreateJoinButtonText();
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = gMainFrame.server.getCurrentRoomName();
|
||||
_loc5_ = _customPartyData[_loc4_];
|
||||
_loc3_ = gMainFrame.userInfo.playerUserInfo;
|
||||
if(_loc2_.indexOf("pparty") == -1 || _loc2_.indexOf(_loc3_.userName) == -1)
|
||||
{
|
||||
PartyManager.sendCustomPartyJoin("",_loc5_.creator,_loc5_.nodeId);
|
||||
}
|
||||
else if(_loc3_.uuid != _loc5_.creator)
|
||||
{
|
||||
PartyManager.sendCustomPartyJoin("",_loc5_.creator,_loc5_.nodeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package Party
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import gui.DarkenManager;
|
||||
|
||||
public class PartyXtCommManager
|
||||
{
|
||||
|
||||
private static var _sphpUsername:String;
|
||||
|
||||
private static var _sphpCallback:Function;
|
||||
|
||||
private static var _spnCallback:Function;
|
||||
|
||||
private static var _spnUsername:String;
|
||||
|
||||
private static var _smCallback:Function;
|
||||
|
||||
public function PartyXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function sendJoinPartyRequest(param1:int) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
gMainFrame.server.setXtObject_Str("sj",[param1]);
|
||||
}
|
||||
|
||||
public static function sendPartyListRequest() : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("sl",[]);
|
||||
}
|
||||
|
||||
public static function sendCustomPartyListRequest(param1:int, param2:int) : void
|
||||
{
|
||||
gMainFrame.server.setXtObject_Str("slp",[param1,param2]);
|
||||
}
|
||||
|
||||
public static function sendCustomPartyJoinRequest(param1:String) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
gMainFrame.server.setXtObject_Str("sjp",[param1]);
|
||||
}
|
||||
|
||||
public static function sendCustomPartyHostRequest(param1:int, param2:Array, param3:int) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
gMainFrame.server.setXtObject_Str("scp",[param1,param2[0],param2[1],param2[2],param3]);
|
||||
}
|
||||
|
||||
public static function sendCustomPartyIsHosting(param1:String, param2:String, param3:Function) : void
|
||||
{
|
||||
if(param2 != null && param2 != "")
|
||||
{
|
||||
_sphpUsername = param1;
|
||||
_sphpCallback = param3;
|
||||
gMainFrame.server.setXtObject_Str("sphp",[param2]);
|
||||
}
|
||||
else if(param3 != null)
|
||||
{
|
||||
param3(0,null);
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendCustomPartyNodeId(param1:String, param2:String, param3:Function) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
_spnUsername = param1;
|
||||
_spnCallback = param3;
|
||||
gMainFrame.server.setXtObject_Str("spn",[param2]);
|
||||
}
|
||||
|
||||
public static function sendPartyMasterpiece(param1:Function) : void
|
||||
{
|
||||
_smCallback = param1;
|
||||
gMainFrame.server.setXtObject_Str("sm",[]);
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
var _loc2_:Object = param1.obj;
|
||||
switch(_loc2_[0])
|
||||
{
|
||||
case "sl":
|
||||
PartyManager.partyListResponse(_loc2_);
|
||||
break;
|
||||
case "sj":
|
||||
PartyManager.roomSoireeResponse(_loc2_);
|
||||
break;
|
||||
case "slp":
|
||||
PartyManager.customPartyListResponse(_loc2_);
|
||||
break;
|
||||
case "scp":
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
PartyManager.customPartyCreateResponse(_loc2_);
|
||||
break;
|
||||
case "sphp":
|
||||
PartyManager.customPartyIsHostingResponse(_loc2_,_sphpUsername,_sphpCallback);
|
||||
_sphpCallback = null;
|
||||
_sphpUsername = "";
|
||||
break;
|
||||
case "sjp":
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
PartyManager.customPartyJoinResponse(_loc2_);
|
||||
break;
|
||||
case "spk":
|
||||
PartyManager.customPartyKillResponse(_loc2_);
|
||||
break;
|
||||
case "spn":
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(_spnCallback != null)
|
||||
{
|
||||
_spnCallback(_spnUsername,_loc2_);
|
||||
_spnCallback = null;
|
||||
_spnUsername = "";
|
||||
}
|
||||
break;
|
||||
case "sm":
|
||||
if(_smCallback != null)
|
||||
{
|
||||
_smCallback(_loc2_[2]);
|
||||
_smCallback = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
package
|
||||
{
|
||||
public class SbiConstants
|
||||
{
|
||||
|
||||
public static const ACCOUNT_TYPE_ARCHIVED:int = -2;
|
||||
|
||||
public static const ACCOUNT_TYPE_NEW:int = -1;
|
||||
|
||||
public static const ACCOUNT_TYPE_NONE:int = 0;
|
||||
|
||||
public static const NON_MEMBER:int = 1;
|
||||
|
||||
public static const PREMIUM_MEMBER:int = 2;
|
||||
|
||||
public static const BETA_MEMBER:int = 3;
|
||||
|
||||
public static const INTERNAL:int = 4;
|
||||
|
||||
public static const COMMUNITY:int = 5;
|
||||
|
||||
public static const INTERACTION_TYPE_BUDDY:int = 0;
|
||||
|
||||
public static const INTERACTION_TYPE_TRADE:int = 1;
|
||||
|
||||
public static const INTERACTION_TYPE_GIFT:int = 2;
|
||||
|
||||
public static const INTERACTION_TYPE_CHAT:int = 3;
|
||||
|
||||
public static const INTERACTION_TYPE_JAG:int = 4;
|
||||
|
||||
public static const INTERACTION_TYPE_MULTIPLAYER:int = 5;
|
||||
|
||||
public static const INTERACTION_TYPE_PVP:int = 6;
|
||||
|
||||
public static const INTERACTION_TYPE_QUEST:int = 7;
|
||||
|
||||
public static const ENVIRO_LAND:int = 0;
|
||||
|
||||
public static const ENVIRO_OCEAN:int = 1;
|
||||
|
||||
public static const ENVIRO_AIR:int = 2;
|
||||
|
||||
public static const ENVIRO_LAND_AND_OCEAN:int = 3;
|
||||
|
||||
public static const ROOMTYPE_WORLD:int = 0;
|
||||
|
||||
public static const ROOMTYPE_GAME:int = 1;
|
||||
|
||||
public static const ROOMTYPE_DEN:int = 2;
|
||||
|
||||
public static const ROOMTYPE_LOBBY:int = 3;
|
||||
|
||||
public static const ROOMTYPE_FFM:int = 4;
|
||||
|
||||
public static const ROOMTYPE_PARTY:int = 5;
|
||||
|
||||
public static const ROOMTYPE_WORLDGAME:int = 6;
|
||||
|
||||
public static const ROOMTYPE_QUEST:int = 7;
|
||||
|
||||
public static const ROOMTYPE_QUEST_STAGING:int = 8;
|
||||
|
||||
public static const CHAT_TYPE_TYPED:int = 0;
|
||||
|
||||
public static const CHAT_TYPE_SAFE:int = 1;
|
||||
|
||||
public static const CHAT_TYPE_EMOTE:int = 2;
|
||||
|
||||
public static const CHAT_TYPE_ACTION:int = 3;
|
||||
|
||||
public static const CHAT_TYPE_ATTACHMENT:int = 4;
|
||||
|
||||
public static const CHAT_TYPE_PERM_EMOTE:int = 5;
|
||||
|
||||
public static const CHAT_TYPE_SLIDE:int = 6;
|
||||
|
||||
public static const CHAT_TYPE_PET_ACTION:int = 7;
|
||||
|
||||
public static const CHAT_TYPE_BLEND_COLOR:int = 8;
|
||||
|
||||
public static const CHAT_TYPE_LIMITED:int = 9;
|
||||
|
||||
public static const CHAT_TYPE_ALPHA_LEVEL:int = 10;
|
||||
|
||||
public static const CHAT_TYPE_CUST_ADVENTURE:int = 11;
|
||||
|
||||
public static const CHAT_TYPE_CUST_PVP:int = 12;
|
||||
|
||||
public static const CHAT_TYPE_BUBBLE:int = 0;
|
||||
|
||||
public static const CHAT_TYPE_FREE:int = 1;
|
||||
|
||||
public static const CHAT_TYPE_PREDICTIVE:int = 2;
|
||||
|
||||
public static const CHAT_TYPE_RESTR_BUBBLE:int = 3;
|
||||
|
||||
public static const PLAYER_WALL_LOCKED:int = 0;
|
||||
|
||||
public static const PLAYER_WALL_BUDDIES:int = 1;
|
||||
|
||||
public static const PLAYER_WALL_EVERYONE:int = 2;
|
||||
|
||||
public static const PLAYER_WALL_WEB_DISABLED:int = 0;
|
||||
|
||||
public static const PLAYER_WALL_WEB_ENABLED:int = 1;
|
||||
|
||||
public static const PLAYER_WALL_TOKEN_LOCKED_FAILURE:int = -1;
|
||||
|
||||
public static const PLAYER_WALL_TOKEN_BUDDIES_FAILURE:int = -2;
|
||||
|
||||
public static const PLAYER_WALL_FAILURE_TOKEN:String = "token";
|
||||
|
||||
public static const PLAYER_WALL_FAILURE_UNAVAILABLE:String = "unavailable";
|
||||
|
||||
public static const LAYER_BASE_ID:int = 1;
|
||||
|
||||
public static const LAYER_PATTERN_ID:int = 2;
|
||||
|
||||
public static const LAYER_EYE_ID:int = 3;
|
||||
|
||||
public static const GEM_CURRENCY:int = 0;
|
||||
|
||||
public static const TICKET_CURRENCY:int = 1;
|
||||
|
||||
public static const CRYSTAL_CURRENCY:int = 2;
|
||||
|
||||
public static const DIAMOND_CURRENCY:int = 3;
|
||||
|
||||
public static const STRAW_CURRENCY:int = 4;
|
||||
|
||||
public static const BAMBOO_CURRENCY:int = 5;
|
||||
|
||||
public static const WOOD_CURRENCY:int = 6;
|
||||
|
||||
public static const STONE_CURRENCY:int = 7;
|
||||
|
||||
public static const SILVER_CURRENCY:int = 8;
|
||||
|
||||
public static const GOLD_CURRENCY:int = 9;
|
||||
|
||||
public static const GEM_STONE_CURRENCY:int = 10;
|
||||
|
||||
public static const ECO_CURRENCY:int = 11;
|
||||
|
||||
public static const NUM_CURRENCY_TYPES:int = 12;
|
||||
|
||||
public static const COMBINED_CURRENCY:int = 100;
|
||||
|
||||
public static const TRADE_OFFER_MAX:int = 20;
|
||||
|
||||
public static const TEXT_RESTRICTION_ENGLISH:String = "A-Za-z0-9!\'.,():?\\- ";
|
||||
|
||||
public static const TEXT_RESTRICTION:String = "A-Za-z0-9À-ÖØ-öø-ÿ!\'.,():?¿¡\\- ";
|
||||
|
||||
public static const PET_INVENTORY_MAX:int = 1000;
|
||||
|
||||
public static const PET_EGG_HATCH_SINGLE_STEP_TIME:int = 86400;
|
||||
|
||||
public static const PET_EGG_HATCH_TIME:int = 259200;
|
||||
|
||||
public static const MAX_EMAIL_LENGTH:int = 50;
|
||||
|
||||
public static const NORMAL_ITEM:int = 0;
|
||||
|
||||
public static const NEW_ITEM:int = 1;
|
||||
|
||||
public static const SALE_ITEM:int = 2;
|
||||
|
||||
public static const CLEARANCE_ITEM:int = 3;
|
||||
|
||||
public static const RARE_ITEM:int = 4;
|
||||
|
||||
public static const DEFAULT_CHAT_COLOR:int = 4531987;
|
||||
|
||||
public static const LE_SUCCESS:int = 1;
|
||||
|
||||
public static const LE_MX_LOOKUP_FAILED:int = 0;
|
||||
|
||||
public static const LE_DEFAULT_FAILURE:int = -1;
|
||||
|
||||
public static const LE_PUNISHER_EMAIL_BLACKLISTED:int = -2;
|
||||
|
||||
public static const LE_PUNISHER_500_RESPONE:int = -3;
|
||||
|
||||
public static const LE_PUNISHER_GENERIC_FAILURE:int = -4;
|
||||
|
||||
public static const PRIVACY_SETTING_LOCKED:int = 0;
|
||||
|
||||
public static const PRIVACY_SETTING_BUDDIES:int = 1;
|
||||
|
||||
public static const PRIVACY_SETTING_EVERYONE:int = 2;
|
||||
|
||||
public static const ACCOUNT_SUBSCRIPTION_TYPE_UNKNOWN:int = 0;
|
||||
|
||||
public static const ACCOUNT_SUBSCRIPTION_TYPE_PROMOTION:int = 11;
|
||||
|
||||
public static const PROMOTION_TYPE_STANDARD:int = 1;
|
||||
|
||||
public static const PROMOTION_TYPE_REFERRAL:int = 2;
|
||||
|
||||
public static const MIN_LENGTH_USERNAME:int = 2;
|
||||
|
||||
public static const MAX_LENGTH_USERNAME_FOR_CREATION:int = 20;
|
||||
|
||||
public static const UV_DEF_CUSTOM_AVT_PROMO_FLAG:int = 0;
|
||||
|
||||
public static const ITEM_TYPE_DEN_ITEM:int = 0;
|
||||
|
||||
public static const ITEM_TYPE_PET:int = 1;
|
||||
|
||||
public static const ITEM_TYPE_CLOTHING:int = 2;
|
||||
|
||||
public static const MIN_ELECTRON_VERSION:String = "1.5.3";
|
||||
|
||||
public static const CURRENCY_NAMES:Vector.<String> = Vector.<String>(["gems","tickets","orbs","diamonds","straw","bamboo","wood","stone","silver","gold","gemstone","ecoCredits"]);
|
||||
|
||||
public static const ACHIEVEMENT_TYPE_NAMES:Array = [23527,22833,22834,22835,22836,22825,22837,22826,22838,22854,22856,22839,22840,22859,22850,22841,22857,22842,22827,22851,22843,22852,22844,22853,22828,22855,22829,22845,22858,23528,22830,22846,22847,22831,22832,22848,22849,29291];
|
||||
|
||||
public static const USERNAME_REGEX:RegExp = /(.*[a-zA-ZÀ-ÏÑ-ÖØ-Üß-ïñ-öø-üÿŸ]){3,}/i;
|
||||
|
||||
public static const EMAIL_REGEX:RegExp = new RegExp(/^[\w%+\.-]+@(?:[a-zA-Z0-9-]+[\.{1}])+[a-zA-Z]{2,}$/i);
|
||||
|
||||
public static const TEXT_PUNCTUATION_ENGLISH:RegExp = /[.!?,]/ig;
|
||||
|
||||
public static const TEXT_PUNCTUATION:RegExp = /[.!?,¿¡]/ig;
|
||||
|
||||
public static const TEXT_IGNORE_FOR_CAPITALIZATION:RegExp = /[\[\]':,\-!().?\";\\/¿¡]/ig;
|
||||
|
||||
public static const PASSWORD_REGEX:Array = ["[A-ZÀ-ÏÑ-ÖØ-Üß-ïñ-öø-üÿŸ]","[a-zß-ïñ-öø-üÿ]","[0-9]"];
|
||||
|
||||
public static const COMMON_DOMAINS:Array = ["yahoo.com","hotmail.com","gmail.com","comcast.net","sbcglobal.net","att.net","msn.com","microsoft.com","aim.com","charter.net","aol.com","cox.net","live.com","live.ca","verizon.net","xtra.co.nz","shaw.ca","bellsouth.net","roadrunner.com","hotmail.co.uk","yahoo.co.uk","optonline.net","centurylink.net","centurytel.net","mail.com","mac.com","google.com","googlemail.com","compuserve.com","myspace.com","facebook.com","youtube.com","netscape.net","emailaccount.com","earthlink.net","rocketmail.com","broadband.com","ymail.com","supermail.com","junkmail.com","mindspring.com","juno.com","prodigy.net","excite.com","frontiernet.net","frontier.com","epix.net","love.com","hellokitty.com","sky.com","pacbell.net","champmail.com","heartmail.com","dragon.com","computer.org","digis.net","yahoo.ca","hotmail.ca","googlemail.co.uk","msn.ca","msn.co.uk","microsoft.co.uk","microsoft.ca","aol.co.uk","live.co.uk","compuserve.co.uk","netscape.ca"];
|
||||
|
||||
public function SbiConstants()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
{
|
||||
import flash.display.Bitmap;
|
||||
|
||||
[Embed(source="/_assets/8_Shadow_png$1df963b087c9c7239527ec2ed626ea3e1163450447.png")]
|
||||
public class Shadow_png$1df963b087c9c7239527ec2ed626ea3e1163450447 extends Bitmap
|
||||
{
|
||||
|
||||
public function Shadow_png$1df963b087c9c7239527ec2ed626ea3e1163450447()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,40 @@
|
||||
package
|
||||
{
|
||||
public class VectorUtility
|
||||
{
|
||||
|
||||
public function VectorUtility()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function safeAdd(param1:*, param2:int, param3:*) : void
|
||||
{
|
||||
while(param2 > param1.length)
|
||||
{
|
||||
param1.push(null);
|
||||
}
|
||||
param1[param2] = param3;
|
||||
}
|
||||
|
||||
public static function vectorToArray(param1:*) : Array
|
||||
{
|
||||
var _loc3_:int = 0;
|
||||
var _loc4_:int = int(param1.length);
|
||||
var _loc2_:Array = [];
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc4_)
|
||||
{
|
||||
_loc2_[_loc3_] = param1[_loc3_];
|
||||
_loc3_++;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public static function sortOn(param1:*, param2:Object, param3:Object = null) : Array
|
||||
{
|
||||
return vectorToArray(param1).sortOn(param2,param3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package
|
||||
{
|
||||
import com.sbi.client.SFEvent;
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import gui.GuiManager;
|
||||
|
||||
public class VersionXtCommManager
|
||||
{
|
||||
|
||||
public function VersionXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function handleXtReply(param1:SFEvent) : void
|
||||
{
|
||||
if(!param1.status)
|
||||
{
|
||||
DebugUtility.debugTrace("ERROR: VersionXtCommManager handleXtReply was called with bad evt.status:" + param1.status);
|
||||
return;
|
||||
}
|
||||
var _loc2_:Array = param1.obj;
|
||||
var _loc3_:* = _loc2_[0];
|
||||
if("userDataVersion" !== _loc3_)
|
||||
{
|
||||
throw new Error("VersionXtCommManager illegal data:" + _loc2_[0]);
|
||||
}
|
||||
avatarVersionResponse(_loc2_);
|
||||
}
|
||||
|
||||
private static function avatarVersionResponse(param1:Array) : void
|
||||
{
|
||||
GuiManager.openVersionPopup(param1[2] == "1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
[Embed(source="/_assets/9_WaterSplash_swf$d6c2db4bff6ebed1f7d66de2e03d1ee2308143425.bin", mimeType="application/octet-stream")]
|
||||
public class WaterSplash_swf$d6c2db4bff6ebed1f7d66de2e03d1ee2308143425 extends ByteArray
|
||||
{
|
||||
|
||||
public function WaterSplash_swf$d6c2db4bff6ebed1f7d66de2e03d1ee2308143425()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
package WorldItems
|
||||
{
|
||||
import Enums.WorldItemDef;
|
||||
import collection.WorldItemCollection;
|
||||
import com.sbi.bit.BitUtility;
|
||||
import com.sbi.popup.SBMysteryMessagePopup;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import currency.UserCurrency;
|
||||
import den.DenItem;
|
||||
import flash.display.MovieClip;
|
||||
import giftPopup.GiftPopup;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
import inventory.Iitem;
|
||||
import item.Item;
|
||||
import item.ItemXtCommManager;
|
||||
import loader.DefPacksDefHelper;
|
||||
import loader.MediaHelper;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class WorldItemsManager
|
||||
{
|
||||
|
||||
private static const USER_VAR_ID_1:int = 439;
|
||||
|
||||
private static const IN_WORLD_LIST_ID:int = 583;
|
||||
|
||||
private static var _worldItems:WorldItemCollection;
|
||||
|
||||
private static var _currRoomWorldItems:Array;
|
||||
|
||||
private static var _usableWorldItems:WorldItemCollection;
|
||||
|
||||
private static var _giftPopup:GiftPopup;
|
||||
|
||||
private static var _currItemDown:WorldItemDef;
|
||||
|
||||
private static var _currGift:Iitem;
|
||||
|
||||
private static var _currGiftColorIndex:int;
|
||||
|
||||
private static var _giftIconMediaHelper:MediaHelper;
|
||||
|
||||
public function WorldItemsManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function requestWorldItemDefs(param1:Array) : void
|
||||
{
|
||||
var _loc2_:DefPacksDefHelper = null;
|
||||
_currRoomWorldItems = param1;
|
||||
if(!_worldItems)
|
||||
{
|
||||
_loc2_ = new DefPacksDefHelper();
|
||||
_loc2_.init(1064,onDefsLoaded,null,2);
|
||||
DefPacksDefHelper.mediaArray[1064] = _loc2_;
|
||||
}
|
||||
else
|
||||
{
|
||||
GenericListXtCommManager.requestGenericList(583);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getWorldItemDef(param1:int) : WorldItemDef
|
||||
{
|
||||
if(_worldItems)
|
||||
{
|
||||
return _worldItems.getWorldDefItem(param1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function handleWorldItemsResponse(param1:WorldItemCollection) : void
|
||||
{
|
||||
_usableWorldItems = param1;
|
||||
setupWorldItemVisibility();
|
||||
}
|
||||
|
||||
public static function onItemDown(param1:Object) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
_currGift = null;
|
||||
_currItemDown = null;
|
||||
_loc2_ = 1;
|
||||
while(_loc2_ < _currRoomWorldItems.length)
|
||||
{
|
||||
if(_currRoomWorldItems[_loc2_].s.content == param1)
|
||||
{
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _usableWorldItems.length)
|
||||
{
|
||||
if(_usableWorldItems.getWorldDefItem(_loc3_).position == _loc2_)
|
||||
{
|
||||
_currItemDown = _usableWorldItems.getWorldDefItem(_loc3_);
|
||||
break;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(_currItemDown)
|
||||
{
|
||||
new SBMysteryMessagePopup(GuiManager.guiLayer,_currItemDown.popupType,_currItemDown.descText,!hasReceivedGift(_currItemDown),onGiftDown);
|
||||
}
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onDefsLoaded(param1:DefPacksDefHelper) : void
|
||||
{
|
||||
DefPacksDefHelper.mediaArray[1064] = null;
|
||||
_worldItems = new WorldItemCollection();
|
||||
for each(var _loc2_:Object in param1.def)
|
||||
{
|
||||
_worldItems.setWorldDefItem(_loc2_.id,new WorldItemDef(_loc2_.id,_loc2_.mediaRefId,LocalizationManager.translateIdOnly(_loc2_.titleStrId),_loc2_.giftType,_loc2_.giftRefId,_loc2_.amount,_loc2_.position,_loc2_.userVarRefId,_loc2_.uvIndex,_loc2_.popupType,uint(_loc2_.availabilityStartTime),uint(_loc2_.availabilityEndTime)));
|
||||
}
|
||||
GenericListXtCommManager.requestGenericList(583);
|
||||
}
|
||||
|
||||
private static function setupWorldItemVisibility() : void
|
||||
{
|
||||
var _loc1_:WorldItemDef = null;
|
||||
var _loc2_:int = 0;
|
||||
var _loc3_:int = 0;
|
||||
_loc2_ = 1;
|
||||
while(_loc2_ < _currRoomWorldItems.length)
|
||||
{
|
||||
_loc1_ = null;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _usableWorldItems.length)
|
||||
{
|
||||
if(_usableWorldItems.getWorldDefItem(_loc3_).position == _loc2_)
|
||||
{
|
||||
_loc1_ = _usableWorldItems.getWorldDefItem(_loc3_);
|
||||
break;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
if(_loc1_ == null)
|
||||
{
|
||||
_currRoomWorldItems[_loc2_].s.content.gotoAndPlay("turnOff");
|
||||
}
|
||||
else if(hasReceivedGift(_loc1_))
|
||||
{
|
||||
_currRoomWorldItems[_loc2_].s.content.gotoAndPlay("empty");
|
||||
}
|
||||
else
|
||||
{
|
||||
_currRoomWorldItems[_loc2_].s.content.gotoAndPlay("turnOn");
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
|
||||
private static function hasReceivedGift(param1:WorldItemDef) : Boolean
|
||||
{
|
||||
return BitUtility.isBitSetForNumber(param1.userVarIndex,gMainFrame.userInfo.userVarCache.getUserVarValueById(param1.userVarRefId));
|
||||
}
|
||||
|
||||
private static function onGiftDown() : void
|
||||
{
|
||||
var _loc1_:Object = null;
|
||||
switch(_currItemDown.giftType)
|
||||
{
|
||||
case 0:
|
||||
_currGift = new DenItem();
|
||||
(_currGift as DenItem).initShopItem(_currItemDown.giftRefId,0,true);
|
||||
break;
|
||||
case 1:
|
||||
_giftIconMediaHelper = new MediaHelper();
|
||||
_giftIconMediaHelper.init(1086,onGiftIconLoaded);
|
||||
break;
|
||||
case 2:
|
||||
_giftIconMediaHelper = new MediaHelper();
|
||||
_giftIconMediaHelper.init(2221,onGiftIconLoaded);
|
||||
break;
|
||||
case 3:
|
||||
_loc1_ = ItemXtCommManager.getItemDef(_currItemDown.giftRefId);
|
||||
if(_loc1_)
|
||||
{
|
||||
_currGiftColorIndex = _loc1_.colors.length * Math.random();
|
||||
_currGift = new Item();
|
||||
(_currGift as Item).init(_currItemDown.giftRefId,0,_loc1_.colors[_currGiftColorIndex],null,true);
|
||||
}
|
||||
}
|
||||
if(_currGift)
|
||||
{
|
||||
_giftPopup = new GiftPopup();
|
||||
_giftPopup.init(GuiManager.guiLayer,_currGift.largeIcon,_currGift.name,_currGift.defId,2,2,onKeepGift,null,onGiftClose);
|
||||
}
|
||||
}
|
||||
|
||||
private static function onGiftIconLoaded(param1:MovieClip) : void
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
_giftIconMediaHelper.destroy();
|
||||
_giftIconMediaHelper = null;
|
||||
switch(_currItemDown.giftType - 1)
|
||||
{
|
||||
case 0:
|
||||
_loc2_ = LocalizationManager.translateIdAndInsertOnly(_currItemDown.giftAmount == 1 ? 11114 : 11097,_currItemDown.giftAmount);
|
||||
break;
|
||||
case 1:
|
||||
_loc2_ = LocalizationManager.translateIdAndInsertOnly(_currItemDown.giftAmount == 1 ? 11116 : 11103,_currItemDown.giftAmount);
|
||||
}
|
||||
_giftPopup = new GiftPopup();
|
||||
_giftPopup.init(GuiManager.guiLayer,param1,_loc2_,_currItemDown.giftAmount,2,2,onKeepGift,null,onGiftClose);
|
||||
}
|
||||
|
||||
private static function onKeepGift() : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(true);
|
||||
WorldItemsXtCommManager.sendAcceptGift(_currItemDown.defId,_currGift && _currGift is DenItem ? (_currGift as DenItem).version : 0,_currGift && _currGift is Item ? _currGiftColorIndex : 0,onGiftResponse);
|
||||
}
|
||||
|
||||
private static function onGiftResponse(param1:String, param2:int) : void
|
||||
{
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
onGiftClose(true);
|
||||
if(param1 == "1")
|
||||
{
|
||||
if(param2 >= 0)
|
||||
{
|
||||
switch(_currItemDown.giftType - 1)
|
||||
{
|
||||
case 0:
|
||||
UserCurrency.setCurrency(param2,0);
|
||||
break;
|
||||
case 1:
|
||||
UserCurrency.setCurrency(param2,3);
|
||||
}
|
||||
}
|
||||
_currRoomWorldItems[_currItemDown.position].s.content.gotoAndPlay("empty");
|
||||
}
|
||||
else
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,LocalizationManager.translateIdOnly(28159));
|
||||
}
|
||||
_currGift = null;
|
||||
_currItemDown = null;
|
||||
}
|
||||
|
||||
private static function onGiftClose(param1:Boolean = false) : void
|
||||
{
|
||||
if(_giftPopup)
|
||||
{
|
||||
_giftPopup.destroy();
|
||||
_giftPopup = null;
|
||||
}
|
||||
if(!param1)
|
||||
{
|
||||
_currGift = null;
|
||||
_currItemDown = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 7925 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user