#****************************************************************************
#**
#**  Author(s):  William Holmes
#**
#**  Summary  :  Cybran Siege Sub Script
#**
#**  Copyright © 2008 OVER NINE THOUSAND!  All rights reserved.
#****************************************************************************

local CSubUnit = import('/lua/cybranunits.lua').CSubUnit
local CANNaniteTorpedoWeapon = import('/lua/cybranweapons.lua').CANNaniteTorpedoWeapon
local CIFMissileCorsairWeapon = import('/lua/cybranweapons.lua').CIFMissileCorsairWeapon

URSX201 = Class(CSubUnit) {
    DestructionTicks = 50,
    
    Weapons = {
        Missile = Class(CIFMissileCorsairWeapon) {},
        Torpedo = Class(CANNaniteTorpedoWeapon) {},
    },
    OnStopBeingBuilt = function(self, builder, layer)
        CSubUnit.OnStopBeingBuilt(self,builder,layer)
        if(self:GetCurrentLayer() == 'Water') then
			# Enable weapon
			self:SetWeaponEnabledByLabel('Missile', true)
        elseif (self:GetCurrentLayer() == 'UnderWater') then
			# Disable Weapon
			self:SetWeaponDisableByLabel('Missile', false)
       end
       self.WeaponsEnabled = true
    end,
	OnLayerChange = function(self, new, old)
		CSubUnit.OnLayerChange(self, new, old)
		if self.WeaponsEnabled then
			if( new == 'Water' ) then
				# Enable Minigun
				self:SetWeaponEnabledByLabel('Missile', true)
			elseif ( new == 'UnderWater' ) then
				# Disable Land Minigun
				self:SetWeaponDisableByLabel('Missile', false)
			end
		end
	end,
}

TypeClass = URSX201