AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

function ENT:Initialize()
    self:SetModel(self:GetModel() or "models/props_c17/oildrum001.mdl")
    self:PhysicsInit(SOLID_VPHYSICS)
    self:SetMoveType(MOVETYPE_VPHYSICS)
    self:SetSolid(SOLID_VPHYSICS)
    self:SetUseType(SIMPLE_USE)
    
    local phys = self:GetPhysicsObject()
    if phys:IsValid() then
        phys:Wake()
    end
end

function ENT:Use(activator, caller)
    if not IsValid(activator) or not activator:IsPlayer() then return end
    
    local vehiclePlugin = ix.plugin.list["vehicles"]
    if vehiclePlugin and vehiclePlugin.GetFactionPoints then
        net.Start("LVS_SyncFactionPoints")
            net.WriteUInt(activator:Team(), 8)
            net.WriteUInt(vehiclePlugin:GetFactionPoints(activator:Team()) or 0, 32)
        net.Send(activator)
    end
    
    local terminalType = self:GetTerminalType()
    if terminalType == "ground" then
        net.Start("LVS_OpenGroundMenu")
        net.Send(activator)
    elseif terminalType == "air" then
        net.Start("LVS_OpenAirMenu") 
        net.Send(activator)
    end
end
