-- ##############################################
-- #	Map Rotate Object						#
-- #											#
-- #	version: 1.1							#
-- #	date: 21.09.2013						#
-- #	author: [FSM]Chefkoch					#
-- #											#
-- # 	Keine Veränderung ohne					# 
-- # 	meine Erlaubnis!						#
-- # 	No modification without					# 
-- # 	my permission!							#
-- #											#
-- #	THX 4 help 2							#
-- #	Sven777b								#
-- #											#
-- #	History:								#
-- #	v1.0 = Projekt started					#
-- #	v1.1 = added X and Z axle support		#
-- #											#
-- ############################################## 

mapRotateObject = {};

local mapRotateObject_mt = Class(mapRotateObject);

function mapRotateObject.onCreate(id)
  g_currentMission:addUpdateable(mapRotateObject:new(id));
end;

function mapRotateObject:new(name)
  local instance = {};
  setmetatable(instance, mapRotateObject_mt);
  instance.objectId = getChildAt(name, 0);
  instance.axleX = Utils.getNoNil(getUserAttribute(name,"x"),10);
  instance.axleY = Utils.getNoNil(getUserAttribute(name,"y"),0);
  instance.axleZ = Utils.getNoNil(getUserAttribute(name,"z"),0);
  
  return instance;
end;

function mapRotateObject:delete()
end;

function mapRotateObject:update(dt)
  local objectRotX = math.rad(self.axleX/360) * dt;
  local objectRotY = math.rad(self.axleY/360) * dt;
  local objectRotZ = math.rad(self.axleZ/360) * dt;
  rotate(self.objectId, objectRotX,objectRotY,objectRotZ);
end;

g_onCreateUtil.addOnCreateFunction("mapRotateObjectOnCreate", mapRotateObject.onCreate);