

AddCSLuaFile()



ENT.Type			= "anim"

ENT.RenderGroup		= RENDERGROUP_OTHER





function ENT:Initialize()

	

	hook.Add( "OnViewModelChanged", self, self.ViewModelChanged )



	self:SetNotSolid( true )

	self:DrawShadow( false )

	self:SetTransmitWithParent( true ) -- Transmit only when the viewmodel does!

	

end



function ENT:DoSetup( ply )



	-- Set these hands to the player

	ply:SetHands( self )

	self:SetOwner( ply )



	-- Which hands should we use?

	local info = GAMEMODE:GetHandsModel( ply )

	if ( info ) then

		self:SetModel( info.model )

		self:SetSkin( info.skin )

		self:SetBodyGroups( info.body )

	end



	-- Attach them to the viewmodel

	local vm = ply:GetViewModel( 0 )

	self:AttachToViewmodel( vm )



	vm:DeleteOnRemove( self )

	ply:DeleteOnRemove( self )



end



local defaultcolor = Vector( 62.0/255.0, 88.0/255.0, 106.0/255.0 )

function ENT:GetPlayerColor()

	local owner = self:GetOwner()

	if owner and owner:IsValid() and owner.GetPlayerColor then

		return owner:GetPlayerColor()

	end



	return defaultcolor

end



function ENT:ViewModelChanged( vm, old, new )



	-- Ignore other peoples viewmodel changes!

	if ( vm:GetOwner() != self:GetOwner() ) then return end



	self:AttachToViewmodel( vm )



end



function ENT:AttachToViewmodel( vm )

	

	self:AddEffects( EF_BONEMERGE )

	self:SetParent( vm )

	self:SetMoveType( MOVETYPE_NONE )



	self:SetPos( Vector( 0, 0, 0 ) )

	self:SetAngles( Angle( 0, 0, 0 ) )



end

