# Path: omnitool/loadbar.py
# class Bar():
#     def __init__(self, size = (500,20), caption = "Loading:", bg = pygame.Color("black"), fg = pygame.Color("grey"),
#                  abortable = True):
# 
#         pygame.display.init()#
#         self.abortable = abortable
#         self.size = size
#         pygame.display.set_caption(caption)
#         self.basecaption = caption
#         self.surface = pygame.display.set_mode(size)
#         self.rect = pygame.Rect((0,0), (0, self.size[1]))
#         self.fg = fg
#         self.bg = bg
#         self.scale = self.size[0]/100
#         self.set_progress(0)
# 
#     def set_progress(self, percent, caption = ""):
#         for event in pygame.event.get():
#             if event.type == 12 and self.abortable:
#                 pygame.quit()
#                 import sys
#                 sys.exit()
#         if caption:
#             pygame.display.set_caption(caption)
#         self.progress = percent
#         self.surface.fill(self.bg)
#         self.rect.width = self.progress*self.scale
#         pygame.gfxdraw.box(self.surface, self.rect, self.fg)
#         pygame.display.update(self.rect)
# 
# Path: omnitool/database.py
# def get_custom_db(txt):
# def parse():
# 
# Path: plugins/planetoids_lib/terragui.py
# def run(main=None):


import sys
    import os
import pygame
            import os
                import time
from math import cos, sin, pi
from collections import defaultdict
from random import *
from omnitool.loadbar import Bar
from omnitool.database import itemlist, names, tiles, ntiles
from omnitool.tinterface import *
from .planetoids_lib import terragui
from .planetoids_lib.tree import make_tree
from .planetoids_lib.terradata import *

        def get_randradrange(pos, minradius, maxradius):
            radius = randint(minradius, maxradius)
            angle = random() * 2 * pi
            return (int(pos[0] + radius * cos(angle)),
                    int(pos[1] + radius * sin(angle)))

        def draw_valuable(min_radius, max_radius, planetpos, material, size):
            r = random() * 2 * pi
            radius = randint(min_radius, max_radius)
            pos = (
            int(planetpos[0] + radius  * cos(r)), int(planetpos[1]+ radius * sin(r)))
            pygame.draw.circle(surface, material, pos, size)

        def make_terra(surface, size):
            pos = (size[0] // 2, size[1] // 2)
            r = superradius
            valuables = (r // 25) ** 2

            pygame.draw.circle(surface, (0, 0, 0), pos, r)  #dirt
            pygame.draw.circle(surface, (30, 30, 30), pos, 3 * r // 4, r // 100)  #wood
            pygame.draw.circle(surface, (1, 1, 1), pos, r // 2)  #stone
            pygame.draw.circle(surface, (59, 59, 59), pos, r // 5)  #jungle
            pygame.draw.circle(surface, (2, 2, 2), pos, r, 2)  #grassring

            for name, minradius, maxradius, amount, size in planetdata:
                minradius = int(r * minradius)
                maxradius = int(r * maxradius)
                for x in range(int(amount * valuables)):
                    npos = get_randradrange(pos, minradius, maxradius)

# Path: omnitool/loadbar.py
# class Bar():
#     def __init__(self, size = (500,20), caption = "Loading:", bg = pygame.Color("black"), fg = pygame.Color("grey"),
#                  abortable = True):
# 
#         pygame.display.init()#
#         self.abortable = abortable
#         self.size = size
#         pygame.display.set_caption(caption)
#         self.basecaption = caption
#         self.surface = pygame.display.set_mode(size)
#         self.rect = pygame.Rect((0,0), (0, self.size[1]))
#         self.fg = fg
#         self.bg = bg
#         self.scale = self.size[0]/100
#         self.set_progress(0)
# 
#     def set_progress(self, percent, caption = ""):
#         for event in pygame.event.get():
#             if event.type == 12 and self.abortable:
#                 pygame.quit()
#                 import sys
#                 sys.exit()
#         if caption:
#             pygame.display.set_caption(caption)
#         self.progress = percent
#         self.surface.fill(self.bg)
#         self.rect.width = self.progress*self.scale
#         pygame.gfxdraw.box(self.surface, self.rect, self.fg)
#         pygame.display.update(self.rect)
# 
# Path: omnitool/database.py
# def get_custom_db(txt):
# def parse():
# 
# Path: plugins/planetoids_lib/terragui.py
# def run(main=None):


# Path: plugins/planetoids.py
import sys
    import os
import pygame
            import os
                import time
from math import cos, sin, pi
from collections import defaultdict
from random import *
from omnitool.loadbar import Bar
from omnitool.database import itemlist, names, tiles, ntiles
from omnitool.tinterface import *
from .planetoids_lib import terragui
from .planetoids_lib.tree import make_tree
from .planetoids_lib.terradata import *


        def get_randradrange(pos, minradius, maxradius):
            radius = randint(minradius, maxradius)
            angle = random() * 2 * pi
            return (int(pos[0] + radius * cos(angle)),
                    int(pos[1] + radius * sin(angle)))

        def draw_valuable(min_radius, max_radius, planetpos, material, size):
            r = random() * 2 * pi
            radius = randint(min_radius, max_radius)
            pos = (
            int(planetpos[0] + radius  * cos(r)), int(planetpos[1]+ radius * sin(r)))
            pygame.draw.circle(surface, material, pos, size)

        def make_terra(surface, size):
            pos = (size[0] // 2, size[1] // 2)
            r = superradius
            valuables = (r // 25) ** 2

            pygame.draw.circle(surface, (0, 0, 0), pos, r)  #dirt
            pygame.draw.circle(surface, (30, 30, 30), pos, 3 * r // 4, r // 100)  #wood
            pygame.draw.circle(surface, (1, 1, 1), pos, r // 2)  #stone
            pygame.draw.circle(surface, (59, 59, 59), pos, r // 5)  #jungle
            pygame.draw.circle(surface, (2, 2, 2), pos, r, 2)  #grassring

            for name, minradius, maxradius, amount, size in planetdata:
                minradius = int(r * minradius)
                maxradius = int(r * maxradius)
                for x in range(int(amount * valuables)):
                    npos = get_randradrange(pos, minradius, maxradius)

                    c = ntiles[name]