#****************************************************************************
#**
#**  File     :  UAB_Annihilator_Script.lua
#**  Author(s):  Resin_Smoker
#**
#**  Summary  :  Aeon Heavy Beam Turret Script
#**
#**  Copyright © 2007
#****************************************************************************

local AStructureUnit = import('/lua/aeonunits.lua').AStructureUnit
local WeaponsFile = import ('/lua/aeonweapons.lua')
local ADFPhasonLaser = WeaponsFile.ADFPhasonLaser
local AIFDisruptorShellWeapon = import('/lua/aeonweapons.lua').AIFDisruptorShellWeapon
local utilities = import('/lua/utilities.lua')

UAB2306 = Class(AStructureUnit) {
    Weapons = {
		MainGun = Class(AIFDisruptorShellWeapon) {},
    },

    OnStopBeingBuilt = function(self, builder, layer)
        AStructureUnit.OnStopBeingBuilt(self, builder, layer)
    #beam emitter rotator
        self.Trash:Add(CreateRotator(self, 'beam_emitter', 'z', nil, 0, 15, 80))
    #sphere rotators
        self:HideBone('sphere', true)
        #self.Trash:Add(CreateRotator(self, 'sphere', 'x', nil, 0, 15, 80 + Random(0, 20)))
        #self.Trash:Add(CreateRotator(self, 'sphere', 'y', nil, 0, 15, 80 + Random(0, 20)))
        #self.Trash:Add(CreateRotator(self, 'sphere', 'z', nil, 0, 15, 80 + Random(0, 20)))
    #sphere energy effects
        self.Trash:Add(CreateAttachedEmitter(self, 'sphere', self:GetArmy(), '/effects/emitters/quark_bomb2_02_emit.bp'))
    #energy beam effects
        self.Trash:Add(AttachBeamEntityToEntity(self, 'beam_emitter', self, 'sphere', self:GetArmy(), '/effects/emitters/zapper_beam_01_emit.bp'))
        self.Trash:Add(AttachBeamEntityToEntity(self, 'beam_point01', self, 'sphere', self:GetArmy(), '/effects/emitters/build_beam_02_emit.bp'))
        self.Trash:Add(AttachBeamEntityToEntity(self, 'beam_point02', self, 'sphere', self:GetArmy(), '/effects/emitters/build_beam_02_emit.bp'))
        self.Trash:Add(AttachBeamEntityToEntity(self, 'beam_point03', self, 'sphere', self:GetArmy(), '/effects/emitters/build_beam_02_emit.bp'))
    end,

    OnDestroy = function(self)
    	if self.Trash then
            self.Trash:Destroy()
        end
    end,

    OnKilled = function(self, instigator, type, overkillRatio)
        AStructureUnit.OnKilled(self, instigator, type, overkillRatio)
        local wep = self:GetWeaponByLabel('MainGun')
        local bp = wep:GetBlueprint()
        if bp.Audio.BeamStop then
            wep:PlaySound(bp.Audio.BeamStop)
        end
        if bp.Audio.BeamLoop and wep.Beams[1].Beam then
            wep.Beams[1].Beam:SetAmbientSound(nil, nil)
        end
        for k, v in wep.Beams do
            v.Beam:Disable()
        end     
    end,
}

TypeClass = UAB2306