import mwpy_gameobject

MWPYGameObject = mwpy_gameobject.MWPYGameObject
MWPYGameObjectType = mwpy_gameobject.MWPYGameObjectType
MWPYGameObjectState = mwpy_gameobject.MWPYGameObjectState


class MWPYLift(MWPYGameObject):
	def __init__(self, gameObjectType = MWPYGameObjectType['MWGOT_LIFT']):
		MWPYGameObject.__init__(self, gameObjectType)
		self.out_actor_status = "AS_LEFT"
		self.is_static = True

	def can_render(self):
		return True
	def can_update(self):
		return True
	def do_update(self, delta, currenttime, world_dict):
		return None

	def update_sprites_state(self, state, offset_x, offset_y):
		pos_x = round( (self.x + offset_x) * mwpy_gameobject.ScrW) / mwpy_gameobject.ScrW
		pos_y = round( (self.y + offset_y) * mwpy_gameobject.ScrH) / mwpy_gameobject.ScrH
		width = round(self.w * 2 * mwpy_gameobject.ScrW) / mwpy_gameobject.ScrW
		height = round(self.h * 2 * mwpy_gameobject.ScrH) / mwpy_gameobject.ScrH
		if(state in self.states_info):
			sprite_list = self.states_info[state]
			for si in sprite_list:
				si.posx = pos_x - 0.5 / mwpy_gameobject.ScrW
				si.width = width
				if(si.name == "LiftSpriteUp"):
					up_sprite = si
				elif(si.name == "LiftSpriteMid"):
					mid_sprite = si
				else:
					down_sprite = si


			up_sprite.height = 0.07924   #58 / 732
			mid_sprite.height = round((self.h * 2 - up_sprite.height) * mwpy_gameobject.ScrW) / mwpy_gameobject.ScrW
			down_sprite.height = 0.01503    #11 / 732

			up_sprite.posy = pos_y
			mid_sprite.posy = pos_y + up_sprite.height
			down_sprite.posy = pos_y + mid_sprite.height + up_sprite.height
			d = 17.0 / 732.0
			mid_sprite.tex_h = (self.h * 2 - up_sprite.height) / d
			return sprite_list

		return []
