from core.environment.sky import SkyRenderable
from core.environment.underground import UndergroundRenderable
import core.biome
import core.component
import core.effect
import core.events
import core.item.armor.attribute
import core.system.registration
import core.terraform
import core.hit_tile

from siege import game
from siege.network import NetworkManager


def register():
    game.events["unregistration"].listen(systemUnregistration)
    game.events['world_loaded'].listen(SkyRenderable.handleWorldLoaded)
    game.events['world_loaded'].listen(UndergroundRenderable.handleWorldLoaded)
    core.biome.register()
    core.component.register()
    core.effect.register()
    core.events.register()
    core.item.armor.attribute.register()
    core.system.registration.register()
    core.terraform.register()
    if NetworkManager.isHost():
        core.hit_tile.register()


def systemUnregistration():
    game.events['world_loaded'].remove(SkyRenderable.handleWorldLoaded)
    game.events['world_loaded'].remove(UndergroundRenderable.handleWorldLoaded)
    core.biome.unregister()
    core.events.unregister()
    core.system.registration.unregister()
    core.terraform.unregister()
    if NetworkManager.isHost():
        core.hit_tile.unregister()
    return True
