do

-----------------------------------------------------------------------------
--  File     : /units/XEL0305/XEL0305_script.lua
--
--  Author(s): EbolaSoup, Resin Smoker, Optimus Prime, Vissroid 
--
--  Summary  : UEF Armored Assault Bot Script (With Hiro Beam Cannon)
--
--  Copyright © 2011 4DC_V0.8  All rights reserved.
-----------------------------------------------------------------------------

local TerranWeaponFile = import('/lua/terranweapons.lua')
local TWalkingLandUnit = import('/lua/terranunits.lua').TWalkingLandUnit
local TDFIonizedPlasmaCannon = TerranWeaponFile.TDFIonizedPlasmaCannon
local TDFHiroPlasmaCannon = TerranWeaponFile.TDFHiroPlasmaCannon

--local OldXEL0305 = XEL0305 -- huh cant be hooked as this class doesnt exist !?!
XEL0305 = Class(TWalkingLandUnit) {

    Weapons = {
        PlasmaCannon01 = Class(TDFIonizedPlasmaCannon) {},
        PlasmaLance= Class(TDFHiroPlasmaCannon) {},
    },
	
	OnStopBeingBuilt = function(self,builder,layer)
        TWalkingLandUnit.OnStopBeingBuilt(self,builder,layer)   
		--disable plasma lance weapon
        self:SetWeaponEnabledByLabel('PlasmaLance', false)
    end,
    
    OnKilled = function(self)
        local wep1 = self:GetWeaponByLabel('PlasmaLance')
        local bp1 = wep1:GetBlueprint()
        if bp1.Audio.BeamStop then
            wep1:PlaySound(bp1.Audio.BeamStop)
        end
        if bp1.Audio.BeamLoop and wep1.Beams[1].Beam then
            wep1.Beams[1].Beam:SetAmbientSound(nil, nil)
        end
        for k, v in wep1.Beams do
            v.Beam:Disable()
        end                 
        TWalkingLandUnit.OnKilled(self)
    end,  

	CreateEnhancement = function(self, enh)
        TWalkingLandUnit.CreateEnhancement(self, enh)
        local bp = self:GetBlueprint().Enhancements[enh]
        if not bp then return end	
			
		if enh == 'PlasmaLance' then
            self:SetWeaponEnabledByLabel('PlasmaLance', true)
		elseif enh == 'PlasmaLanceRemove' then 
			self:SetWeaponEnabledByLabel('PlasmaLance', false)
		end	
	end,
}

TypeClass = XEL0305

end