Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.07 KB | None | 0 0
  1. #include "VehicleCommon.as"
  2.  
  3. class vehiblock
  4. {
  5.     u16[][] tileids = { { 0 } }; //tileid in world.png
  6.     u16[][] blobids = { { 0 } }; //netid
  7.     u32[][] thisblock = { { 0 } }; //sprite layer id, recode this shit so we use vec2f coords into spritelayers
  8.  
  9.     u32 curblock;
  10.  
  11.     vehiblock()
  12.     {
  13.     }
  14. }
  15.  
  16. void onInit(CBlob@ this)
  17. {
  18.     vehiblock blockclass;
  19.     this.set("blockclass", blockclass);
  20.  
  21.     for(int i = 0; i < 16; i += 1)
  22.     {
  23.         for(int j = 0; j < 16; j += 1)
  24.         {
  25.             addTile(this, Vec2f(i, j), getMap().getTile(Vec2f(i, j)).type);
  26.         }
  27.     }
  28.  
  29.     /*Vehicle_Setup( this,
  30.                    95.0f, // move speed
  31.                    0.19f,  // turn speed
  32.                    Vec2f(0.0f, -5.0f), // jump out velocity
  33.                    true  // inventory access
  34.                  );
  35.     VehicleInfo@ v;
  36.     if (!this.get( "VehicleInfo", @v )) {
  37.         return;
  38.     }*/
  39.  
  40.     this.setPosition(Vec2f(this.getPosition().x, this.getPosition().y - 128));
  41. }
  42.  
  43. void addTile(CBlob@ this, Vec2f pos, u16 id)
  44. {
  45.     vehiblock@ block;
  46.     if (!this.get("blockclass", @block)) return;
  47.  
  48.     if (block.thisblock.size() < pos.x)        { block.thisblock.resize(Maths::Ceil(pos.x)+1);        block.tileids.resize(Maths::Ceil(pos.x)+1);        block.blobids.resize(Maths::Ceil(pos.x)+1);        } // serial eyekiller
  49.     if (block.thisblock[pos.x].size() < pos.y) { block.thisblock[pos.x].resize(Maths::Ceil(pos.y)+1); block.tileids[pos.x].resize(Maths::Ceil(pos.y)+1); block.blobids[pos.x].resize(Maths::Ceil(pos.y)+1); }
  50.  
  51.     block.thisblock[pos.x][pos.y] = block.thisblock[pos.x][pos.y] + 1;
  52.     block.tileids[pos.x][pos.y] = id;
  53.  
  54.     Vec2f[] vertex = { pos, Vec2f(pos.x+8, pos.y), Vec2f(pos.x+8, pos.y+8), Vec2f(pos.x, pos.y+8) };
  55.     this.getShape().AddShape(vertex);
  56.  
  57.     CSpriteLayer@ tile = this.getSprite().addSpriteLayer("tile" + block.thisblock[pos.x][pos.y], "world.png", 8, 8); //if they implant non 8x8 rectangles we're fucked
  58.     tile.SetVisible(true);
  59.     tile.SetOffset(pos);
  60.     tile.SetFrame(id);
  61. }
  62.  
  63. void onTick( CBlob@ this )
  64. {
  65.     /*if (this.hasAttached() || this.getTickSinceCreated() < 30) //driver, seat or gunner, or just created
  66.     {
  67.         VehicleInfo@ v;
  68.         if (!this.get( "VehicleInfo", @v )) {
  69.             return;
  70.         }
  71.  
  72.         Vehicle_StandardControls( this, v );
  73.  
  74.         AttachmentPoint@[] aps;      
  75.         if (this.getAttachmentPoints( @aps ))
  76.         {
  77.             CSprite@ sprite = this.getSprite();
  78.             uint flyerCount = 0;
  79.             for (uint i = 0; i < aps.length; i++)
  80.             {
  81.                 AttachmentPoint@ ap = aps[i];
  82.                 if (ap.name == "FLYER")
  83.                 {    
  84.                     CBlob@ blob = ap.getOccupied();
  85.                     CSpriteLayer@ propeller = sprite.getSpriteLayer( flyerCount );
  86.                 }
  87.             }
  88.         }
  89.     }*/
  90. }
  91.  
  92. void Vehicle_onFire( CBlob@ this, VehicleInfo@ v, CBlob@ bullet, const u8 charge ) {}
  93. bool Vehicle_canFire( CBlob@ this, VehicleInfo@ v, bool isActionPressed, bool wasActionPressed, u8 &out chargeValue ) {return false;}
  94.  
  95. bool doesCollideWithBlob( CBlob@ this, CBlob@ blob )
  96. {
  97.     return Vehicle_doesCollideWithBlob_boat( this, blob );
  98. }            
  99.  
  100. bool canBePickedUp( CBlob@ this, CBlob@ byBlob )
  101. {
  102.     return false;
  103. }
  104.  
  105. // SPRITE
  106.  
  107. void onInit( CSprite@ this )
  108. {
  109. }
  110.  
  111. void onTick( CSprite@ this )
  112. {
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement