from core.system.combat import CombatSystem
from core.system.conflict import ConflictSystem
from core.system.command import CommandSystem, populateCommands
from core.system.grass import GrassSystem
from core.system.input import InputSystem
from core.system.music import MusicSystem
from core.system.research import ResearchSystem
from core.system.server import ServerHandler
from core.system.settings import SettingsSystem
from core.system.spawner import SpawnerSystem
from core.system.travel import TravelSystem
from core.system.treasure import TreasureSystem
from core.system.tween import TweenSystem

from siege import game


def register():
    game.events["populate_command"].listen(populateCommands)
    game.events['world_loaded'].listen(GrassSystem.register)
    game.events['world_unloaded'].listen(GrassSystem.unregister)
    game.events['world_loaded'].listen(TreasureSystem.register)
    game.events['world_unloaded'].listen(TreasureSystem.unregister)
    game.events["world_loaded"].listen(ServerHandler.registration)
    game.events["world_loaded"].listen(InputSystem.register)
    game.events["world_unloaded"].listen(InputSystem.unregister)
    CombatSystem.register()
    ConflictSystem.register()
    ResearchSystem.register()
    TravelSystem.register()
    CommandSystem.register()
    TweenSystem.register()
    MusicSystem.register()
    SettingsSystem.register()
    SpawnerSystem.register()


def unregister():
    game.events['world_loaded'].remove(GrassSystem.register)
    game.events['world_unloaded'].remove(GrassSystem.unregister)
    game.events['world_loaded'].remove(TreasureSystem.register)
    game.events['world_unloaded'].remove(TreasureSystem.unregister)
    game.events["world_loaded"].remove(InputSystem.register)
    game.events["world_unloaded"].remove(InputSystem.unregister)
    CombatSystem.unregister()
    ConflictSystem.unregister()
    TravelSystem.unregister()
