AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
ENT.hp = 500

function ENT:Initialize()
	self:SetModel(self.Model)
	self:PhysicsInit(6)

end

function ENT:Think()
	
end

function ENT:OnRemove()

end

function ENT:Use(activator, caller)
	if activator:GetActiveWeapon():GetClass() == "engineertool" or "engineertoolfpv" or "engineertoolmines" then
		print(activator:GetActiveWeapon().Structures)
		activator:GetActiveWeapon().Structures[self.ItemId].count = activator:GetActiveWeapon().Structures[self.ItemId].count + self.ItemCount
		net.Start('additem')
		net.WriteInt(self.ItemId, 13)
		net.WriteInt(self.ItemCount, 13)
		net.Send(activator)
		self:Remove()
	end
end

function ENT:OnTakeDamage( dmg )
	if dmg:GetInflictor() == self or dmg:GetAttacker() == self then return end
	if self.Exploded then return end
	if self.hp > 0 and self.hp - dmg:GetDamage() <= 0 then
		self.Exploded = true
		self:Remove()
	end
	self.hp = self.hp - dmg:GetDamage()
	dmg:SetAttacker(self)
	dmg:SetInflictor(self)
	self:TakePhysicsDamage( dmg )
end
