#****************************************************************************
#**
#**  File     :  /data/units/XSB1104/XSB1104_script.lua
#**  Author(s):  Jessica St. Croix
#**
#**  Summary  :  Seraphim Mass Fabricator
#**
#**  Copyright © 2007 Gas Powered Games, Inc.  All rights reserved.
#****************************************************************************

local SMassFabricationUnit = import('/lua/seraphimunits.lua').SMassFabricationUnit

USBX202 = Class(SMassFabricationUnit) {

    OnStopBeingBuilt = function(self,builder,layer)
        SMassFabricationUnit.OnStopBeingBuilt(self,builder,layer)
        self.Rotator1 = (CreateRotator(self, 'Spinner01', 'y', nil, 0, 10, 350))
        self.Rotator2 = (CreateRotator(self, 'Spinner02', 'y', nil, 0, 5, 100))
        self.Rotator3 = (CreateRotator(self, 'Spinner03', 'y', nil, 0, -8, -150))
        self.Rotator4 = (CreateRotator(self, 'Spinner04', 'y', nil, 0, 11, 200))
        self.Rotator5 = (CreateRotator(self, 'Spinner05', 'y', nil, 0, -15, -250))
        self.Rotator6 = (CreateRotator(self, 'Spinner06', 'y', nil, 0, 19, 300))
        self.Rotator7 = (CreateRotator(self, 'Base', 'y', nil, 0, -5, -50))
        self.Trash:Add(self.Rotator1)
        self.Trash:Add(self.Rotator2)
        self.Trash:Add(self.Rotator3)
        self.Trash:Add(self.Rotator4)
        self.Trash:Add(self.Rotator5)
		self.Trash:Add(self.Rotator6)
		self.Trash:Add(self.Rotator7)
        ChangeState(self, self.ActiveState)
    end,

    ActiveState = State {
        Main = function(self)
            self.Rotator1:SetSpinDown(false)
            self.Rotator1:SetTargetSpeed(350)
            self.Rotator2:SetSpinDown(false)
            self.Rotator2:SetTargetSpeed(100)
            self.Rotator3:SetSpinDown(false)
            self.Rotator3:SetTargetSpeed(-150)
            self.Rotator4:SetSpinDown(false)
            self.Rotator4:SetTargetSpeed(200)
            self.Rotator5:SetSpinDown(false)
            self.Rotator5:SetTargetSpeed(-250)
            self.Rotator6:SetSpinDown(false)
            self.Rotator6:SetTargetSpeed(300)
            self.Rotator7:SetSpinDown(false)
            self.Rotator7:SetTargetSpeed(-50)
        end,

        OnProductionPaused = function(self)
            SMassFabricationUnit.OnProductionPaused(self)
            ChangeState(self, self.InActiveState)
        end,
    },

    InActiveState = State {
        Main = function(self)
            self.Rotator1:SetSpinDown(true)
            self.Rotator2:SetSpinDown(true)
            self.Rotator3:SetSpinDown(true)
            self.Rotator4:SetSpinDown(true)
            self.Rotator5:SetSpinDown(true)
            self.Rotator6:SetSpinDown(true)
            self.Rotator7:SetSpinDown(true)
            WaitFor(self.Rotator1)
        end,

        OnProductionUnpaused = function(self)
            SMassFabricationUnit.OnProductionUnpaused(self)
            ChangeState(self, self.ActiveState)
        end,
    },
}

TypeClass = USBX202