Advertisement
liuwong

portal: others

May 4th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package example.portal
  2. {
  3.     import nape.geom.Vec2;
  4.     import nape.phys.Body;
  5.     import nape.shape.Shape;
  6.    
  7.     /**
  8.      * ...
  9.      * @author liu wong
  10.      *
  11.      */
  12.    
  13.     public class Portal
  14.     {
  15.         public var target:Portal; // where entering this portal takes you
  16.         public var collide:Array/*Shape*/; // shapes to always collide with belonging to portal when passing through
  17.         public var ignore:Array/*Shape*/; // shapes to never collide with belonging to portal whe passing through
  18.  
  19.         public var body:Body;
  20.         public var sensor:Shape;
  21.         public var position:Vec2; // position of portal centre (local to body)
  22.         public var direction:Vec2; // direction of portal (local to body)
  23.         public var width:Number; // width of portal
  24.        
  25.         public function Portal(trgt:Portal, cld:Array, ignr:Array, bdy:Body, snsr:Shape, pos:Vec2, dir:Vec2, wdth:Number):void
  26.         {
  27.             target = trgt;
  28.             collide = cld;
  29.             ignore = ignr;
  30.            
  31.             body = bdy;
  32.             sensor = snsr;
  33.             position = pos;
  34.             direction = dir;
  35.             width = wdth;
  36.         }
  37.     }
  38.    
  39. }
  40.  
  41. package example.portal
  42. {
  43.     import nape.phys.Body;
  44.    
  45.     /**
  46.      * ...
  47.      * @author liu wong
  48.      *
  49.      */
  50.    
  51.     public class PortalPair
  52.     {
  53.         public var portalA:Portal;
  54.         public var portalB:Portal;
  55.         public var bodyA:Body;
  56.         public var bodyB:Body;
  57.        
  58.         public function PortalPair(pA:Portal, pB:Portal, bA:Body, bB:Body):void
  59.         {
  60.             portalA = pA;
  61.             portalB = pB;
  62.             bodyA = bA;
  63.             bodyB = bB;
  64.         }
  65.     }
  66.    
  67. }
  68.  
  69. package example.portal
  70. {
  71.     import example.portal.Portal;
  72.    
  73.     /**
  74.      * ...
  75.      * @author liu wong
  76.      *
  77.      */
  78.    
  79.     public class PortalShapeData
  80.     {
  81.         public var portal:Portal;
  82.         public var portal_target:Boolean;
  83.        
  84.         public function PortalShapeData(p:Portal, ptarget:Boolean):void
  85.         {
  86.             portal = p;
  87.             portal_target = ptarget;
  88.         }
  89.     }
  90.    
  91. }
  92.  
  93. package example.portal
  94. {
  95.    
  96.     /**
  97.      * ...
  98.      * @author liu wong
  99.      *
  100.      */
  101.    
  102.     public class PortableShapeData
  103.     {
  104.         public var portal_id:int;
  105.         public var portals:Array/*PortalShapeData*/;
  106.         public var portal_active:int;
  107.     }
  108.    
  109. }
  110.  
  111. package example.portal
  112. {
  113.     import example.portal.PortalPair;
  114.    
  115.     /**
  116.      * ...
  117.      * @author liu wong
  118.      *
  119.      */
  120.    
  121.     public class PortableBodyData
  122.     {
  123.         public var portal_pairs:Array/*PortalPair*/;
  124.     }
  125.    
  126. }
  127.  
  128. package example.portal
  129. {
  130.    
  131.     /**
  132.      * ...
  133.      * @author liu wong
  134.      *
  135.      */
  136.    
  137.     public class PortalSensorData
  138.     {
  139.         public var portal:Portal;
  140.     }
  141.    
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement