ENT.Type = "anim"
ENT.PrintName = "Военкомат"
ENT.Category = "[FT] Система документов"
ENT.Spawnable = true
ENT.AdminOnly = true
ENT.RenderGroup = RENDERGROUP_BOTH

function ENT:SetupDataTables()
end

if SERVER then
    function ENT:Initialize()
        self:SetModel("models/props_lab/monitor02.mdl")
        self:PhysicsInit(SOLID_VPHYSICS)
        self:SetMoveType(MOVETYPE_NONE)
        self:SetSolid(SOLID_VPHYSICS)
        self:SetUseType(SIMPLE_USE)
        
        local phys = self:GetPhysicsObject()
        if IsValid(phys) then
            phys:EnableMotion(false)
        end
    end
    
    function ENT:Use(activator, caller)
        if not IsValid(activator) or not activator:IsPlayer() then
            return
        end
        
        local character = activator:GetCharacter()
        if not character then
            return
        end
        
        -- Проверяем, есть ли уже военный билет
        local inventory = character:GetInventory()
        if inventory then
            for _, item in pairs(inventory:GetItems()) do
                if item.uniqueID == "military_id" then
                    activator:Notify("У вас уже есть военный билет!")
                    return
                end
            end
        end
        
        -- Открываем опросник
        net.Start("ixMilitaryID_OpenQuiz")
        net.Send(activator)
    end
else
    function ENT:Draw()
        self:DrawModel()
        
        local plugin = ix.plugin.Get("military_id")
        if not plugin then return end
        
        local pos = self:GetPos() + self:GetUp() * 30
        local ang = self:GetAngles()
        
        ang:RotateAroundAxis(ang:Forward(), 90)
        ang:RotateAroundAxis(ang:Right(), -90)
        
        cam.Start3D2D(pos, ang, 0.1)
            draw.SimpleTextOutlined(
                plugin.terminalText or "ВОЕНКОМАТ",
                "DermaLarge",
                0, 0,
                Color(255, 255, 255),
                TEXT_ALIGN_CENTER,
                TEXT_ALIGN_CENTER,
                2,
                Color(0, 0, 0)
            )
        cam.End3D2D()
    end
end
