###########################################################
# LoadModels - Railshooter Module
# Preloads Models
###########################################################

# DESCRIPTION:
# This Class pre-loads the models that are used in the game.
# The models are added to the ModelPool, which allows them
# to be used as Copies later on via the loader.loadModelCopy command.
# Using the ModelPool greatly lessens the strain of the duplicate
# models on the computer. 


from direct.showbase.ShowBaseGlobal import *
from direct.actor import Actor
import Level1
    
########################################
# Preload Models into Model Pool
########################################
# Also Loads the Earlier so no Hitches occur during Gameplay

# Preload Plane Object for Animated Texture Map Movies
plane = ModelPool.loadModel('Models/basics/plane')

# Preloads Environment
skybox = ModelPool.loadModel('Models/skybox/sunsetSkybox2')
city = ModelPool.loadModel('Models/city/SuperCity')

# Preloads Enemies
enemya = ModelPool.loadModel('Models/enemies/DeuceHopper')
enemy1 = loader.loadModelCopy('Models/enemies/DeuceHopper')
enemy1.reparentTo(Level1.railDummy)
enemy1.setPos(0, 300, 55)

enemyb = ModelPool.loadModel('Models/enemies/NewHopper')
enemy2 = loader.loadModelCopy('Models/enemies/NewHopper')
enemy2.reparentTo(Level1.railDummy)
enemy2.setPos(0, 300, 55)

enemyc = ModelPool.loadModel('Models/enemies/BugHopper')
enemy3 = loader.loadModelCopy('Models/enemies/BugHopper')
enemy3.reparentTo(Level1.railDummy)
enemy3.setPos(0, 300, 55)

enemyd = ModelPool.loadModel('Models/enemies/PowerHopper')
enemy4 = loader.loadModelCopy('Models/enemies/PowerHopper')
enemy4.reparentTo(Level1.railDummy)
enemy4.setPos(0, 300, 55)

# Preload Projectiles
plasmashot1 = ModelPool.loadModel("Models/effects/plasmaShot5")
plasma = loader.loadModelCopy('Models/effects/plasmaShot5')
plasma.reparentTo(Level1.railDummy)
plasma.setPos(0, 300, 55)

circleProjectile1 = ModelPool.loadModel("Models/effects/circleProjectile")
circleProjectile = loader.loadModelCopy('Models/effects/circleProjectile')
circleProjectile.reparentTo(Level1.railDummy)
circleProjectile.setPos(0, 300, 55)

laser1 = ModelPool.loadModel("Models/effects/laser")
laser = loader.loadModelCopy('Models/effects/laser')
laser.reparentTo(Level1.railDummy)
laser.setPos(0, 300, 55)

regBlast1 = ModelPool.loadModel("Models/effects/regBlast")
regBlast = loader.loadModelCopy('Models/effects/regBlast')
regBlast.reparentTo(Level1.railDummy)
regBlast.setPos(0, 300, 55)

missile1 = ModelPool.loadModel("Models/effects/RailRocket")
missile = loader.loadModelCopy('Models/effects/RailRocket')
missile.reparentTo(Level1.railDummy)
missile.setPos(0, 300, 55)

# Preload Powerup Meshes
powerup1 = ModelPool.loadModel("Models/powerup/Powerup")
powerup = loader.loadModelCopy("Models/powerup/Powerup")
powerup.reparentTo(Level1.railDummy)
powerup.setPos(0, 300, 55)

# Preload Player Meshes
airblade = ModelPool.loadModel("Models/airblade/airblade")

# Preload Boss Body Attachment Meshes
lArm1 = ModelPool.loadModel("Models/boss/boss-larmlower")
lArm = loader.loadModelCopy('Models/boss/boss-larmlower')
lArm.reparentTo(Level1.railDummy)
lArm.setPos(0, 300, 55)

rArm1 = ModelPool.loadModel("Models/boss/boss-rarmlower")
rArm = loader.loadModelCopy('Models/boss/boss-rarmlower')
rArm.reparentTo(Level1.railDummy)
rArm.setPos(0, 300, 55)

head1 = ModelPool.loadModel("Models/boss/boss-head")
head = loader.loadModelCopy('Models/boss/boss-head')
head.reparentTo(Level1.railDummy)
head.setPos(0, 300, 55)

chest1 = ModelPool.loadModel("Models/boss/boss-chest")
chest = loader.loadModelCopy('Models/boss/boss-chest')
chest.reparentTo(Level1.railDummy)
chest.setPos(0, 300, 55)


########################################
# Preload Actors
########################################
# This Method Preloads all Actors by showing them on screen 
# briefly at the start of the world.

bossModel = Actor.Actor("Models/boss/boss-skeleton",
			{'idle':'Models/boss/boss-idle',
			'pain':'Models/boss/boss-pain',
			'hit':'Models/boss/boss-hit',
			'leftfire':'Models/boss/boss-leftfire',
			'rightfire':'Models/boss/boss-rightfire'})
bossModel.setScale(0.6, 0.6, 0.6)
bossModel.reparentTo(Level1.railDummy)
bossModel.setPos(0, 300, 55)


# Hide all the Preloaded Models
# Call before game starts
def hidePreloaders():
    bossModel.hide()
    enemy1.hide()
    enemy2.hide()
    enemy3.hide()
    enemy4.hide()
    plasma.hide()
    circleProjectile.hide()
    regBlast.hide()
    laser.hide()
    missile.hide()
    powerup.hide()
    lArm.hide()
    rArm.hide()
    chest.hide()
    head.hide()
