AddCSLuaFile()

ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Constructor Prop"

function ENT:Initialize()
    if CLIENT then return end
    
    self:SetModel(self.Model or "models/props_c17/oildrum001.mdl")
    self:PhysicsInit(SOLID_VPHYSICS)
    self:SetMoveType(MOVETYPE_VPHYSICS)
    self:SetSolid(SOLID_VPHYSICS)
    
    local phys = self:GetPhysicsObject()
    if IsValid(phys) then
        phys:EnableMotion(false)
        phys:SetMass(500)
    end
    
    self.hp = self.InitialHealth or 10000
    
    self:DrawShadow(true)
    self:SetCollisionGroup(COLLISION_GROUP_NONE)
end

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

if CLIENT then
    function ENT:Draw()
        self:DrawModel()
    end
end
