<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<object>
  <spriteName>spr_chunk</spriteName>
  <solid>0</solid>
  <visible>-1</visible>
  <depth>0</depth>
  <persistent>0</persistent>
  <parentName>&lt;undefined&gt;</parentName>
  <maskName>&lt;undefined&gt;</maskName>
  <events>
    <event eventtype="0" enumb="0">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>/// GENERATE CHUNK
instance_list = ds_list_create();
loaded = true;
var hasGeneratedBlackHole = false;

// GENERATION
for(var xx = 0; xx &lt; CHUNK_SIZE*TILE_SIZE; xx+= TILE_SIZE)
{
    for(var yy = 0; yy &lt; CHUNK_SIZE*TILE_SIZE; yy+= TILE_SIZE)
    {
        var rnd = random_range(0,5000);
        
        if(floor(rnd) == 1000)
        {   
            if(hasGeneratedBlackHole)
                continue;
            var inst = instance_create(x+xx,y+yy, obj_black_hole);
            inst.CHUNK_CONTAINED = self.id;
            ds_list_add(instance_list, inst);
            
            hasGeneratedBlackHole = true;
            continue;
        }
        if(rnd % 100 &lt; 1)
        {
            var inst = instance_create(x+xx,y+yy, obj_asteriod);
            inst.CHUNK_CONTAINED = self.id;
            
            ds_list_add(instance_list, inst);
            continue;
        }
    }
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="3" enumb="0">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>///Place blocks
if(mouse_check_button_pressed(mb_right) || gamepad_button_check_pressed(0,gp_shoulderl))
{
    if(obj_inv_controller.is_open)
    {
        return 0;
    }
    
    var selected_item = obj_inv_controller.inventory[obj_hotbar.selected_slot];
    
    if(selected_item != 0)
    {
        var selX = round(mouse_x/TILE_SIZE)*TILE_SIZE;
        var selY = round(mouse_y/TILE_SIZE)*TILE_SIZE;
        selX -= TILE_SIZE / 2;
        selY -= TILE_SIZE / 2;
    
        var objid = instance_position(selX,selY,obj_placed_item)
        if(objid != noone)
        {
            show_debug_message(string(objid)+", "+string(objid.object_index));
            return 0;
        }
        
        objid = instance_position(selX,selY,obj_player)
        if(objid != noone)
        {
            show_debug_message(string(objid)+", "+string(objid.object_index));
            return 0;
        }
        
        var inst = instance_create(selX,selY,obj_placed_item);
        use_item_in_inventory(obj_hotbar.selected_slot);
        var chunkid = id;
        with(inst){
            inst.ITEM_ID = selected_item;
            inst.CHUNK_CONTAINED = chunkid;
        }
        ds_list_add(instance_list, inst);
    }
}
</string>
          </argument>
        </arguments>
      </action>
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>var chunk_total_size = CHUNK_SIZE * TILE_SIZE


if(distance_to_object(obj_player) &gt; chunk_total_size*3)
{
    event_user(0); 
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="11">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>/// load

for(var i = 0; i &lt; ds_list_size(instance_list); i++)
{
    instance_activate_object(instance_list[| i]);
}
loaded = true;
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="10">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>/// unload
for(var i = 0; i &lt; ds_list_size(instance_list); i++)
{
    instance_deactivate_object(instance_list[| i]);
}
loaded = false;
instance_deactivate_object(id);
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="8" enumb="0">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>if(global.debug)
    draw_self();
    
var selX = round(mouse_x/TILE_SIZE)*TILE_SIZE;
var selY = round(mouse_y/TILE_SIZE)*TILE_SIZE;
selX -= TILE_SIZE / 2;
selY -= TILE_SIZE / 2;

draw_set_color(c_white);
draw_rectangle(selX,selY,selX + TILE_SIZE, selY + TILE_SIZE, true);

</string>
          </argument>
        </arguments>
      </action>
    </event>
  </events>
  <PhysicsObject>0</PhysicsObject>
  <PhysicsObjectSensor>0</PhysicsObjectSensor>
  <PhysicsObjectShape>0</PhysicsObjectShape>
  <PhysicsObjectDensity>0.5</PhysicsObjectDensity>
  <PhysicsObjectRestitution>0.100000001490116</PhysicsObjectRestitution>
  <PhysicsObjectGroup>0</PhysicsObjectGroup>
  <PhysicsObjectLinearDamping>0.100000001490116</PhysicsObjectLinearDamping>
  <PhysicsObjectAngularDamping>0.100000001490116</PhysicsObjectAngularDamping>
  <PhysicsObjectFriction>0.200000002980232</PhysicsObjectFriction>
  <PhysicsObjectAwake>-1</PhysicsObjectAwake>
  <PhysicsObjectKinematic>0</PhysicsObjectKinematic>
  <PhysicsShapePoints/>
</object>
