from math import ceil

from direct.showbase.ShowBase import ShowBase
from panda3d.core import BitMask32

base = ShowBase()
pedestrian_colliders = dict()
building_colliders = dict()
living_police = 0

pedestrian_spawnpoints = list()  # list of vec3s. The z component indicates radius
minor_spawnpoints = list()

EASY = 0
NORMAL = 1
HARD = 2
DIFFICULTY = NORMAL

COLOR_TO_WIN = ''
BUILDINGS_TO_DESTROY = 0
BUILDINGS_DESTROYED = 0

PAUSED = [False]
STARS = [0, 0.0]
STAR_DECREASE_PER_SECOND = 1/20
STARS_BUILDING_DESTRUCTION = 3
STARS_ENEMY_DEATH = 1/10
STARS_NEUTRAL_DEATH = 1
STARS_NEUTRAL_ATTACK = 1/50 + STAR_DECREASE_PER_SECOND

BUILDING_MASK = BitMask32(0x80)
BUILDING_CLICK_MASK = BitMask32(0x800)
PERSON_CLICK_MASK = BitMask32(0x100)
PLANE_MASK = BitMask32(0x400)
CITY_SIZE = 48

PARTICLES = True

from colors import color_vectors, tweak_material

googily = base.loader.load_font('font/Googily.otf', color=(1, 1, 1, 1))
numberfont = base.loader.load_font('font/grotesque.ttf', color=(1, 0.851, 0.294, 0.8))
nexus = base.loader.load_font('font/grotesque.ttf', color=(1, 1, 1, 1))
comic_neue = base.loader.load_font('font/comic-neue.ttf', color=(1, 1, 1, 1))


def star_update(task):
    STARS[1] -= globalClock.getDt() * STAR_DECREASE_PER_SECOND
    STARS[1] = min(10, max(STARS[1], 0))
    STARS[0] = int(ceil(STARS[1]))
    if STARS[0] > 10:
        STARS[0] = 10
    return task.cont


GAME_OVER_LISTENERS = []


base.task_mgr.add(star_update)
