local imgui = require('mimgui')
local sightState = {
rotation = 0,
lastTime = os.clock(),
pulsePhase = 0
}
---@param centerX number X центр экрана
---@param centerY number Y центр экрана
---@param size number Размер в пикселях
---@param targetX number|nil X цели (опционально)
---@param targetY number|nil Y цели (опционально)
---@param isLocked boolean Цвет: true=синий(захват), false=розовый(поиск)
function imgui.TargetSight(centerX, centerY, size, targetX, targetY, isLocked)
local now = os.clock()
local delta = now - sightState.lastTime
sightState.lastTime = now
sightState.rotation = (sightState.rotation + delta * 0.85) % (math.pi * 2)
sightState.pulsePhase = sightState.pulsePhase + delta * 7.5
local DL = imgui.GetBackgroundDrawList()
local pulse = 0.8 + 0.25 * math.sin(now * 5.5)
local visualSize = size * pulse
local colors = {
primary = isLocked and {0.0, 0.85, 1.0, 1.0} or {1.0, 0.25, 0.8, 1.0},
accent = {0.15, 1.0, 0.35, 0.9},
glow = {0.0, 0.7, 1.0, 0.22},
ray = {0.35, 0.75, 1.0, 0.12}
}
for i = 0, 5 do
local angle = sightState.rotation + i * math.pi / 3
local endX = centerX + math.cos(angle) * visualSize * 1.7
local endY = centerY + math.sin(angle) * visualSize * 1.7
DL:AddLine(
imgui.ImVec2(centerX, centerY),
imgui.ImVec2(endX, endY),
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack(colors.ray))),
0.65
)
end
local triangle = {}
for i = 0, 2 do
local angle = sightState.rotation + i * math.pi * 2 / 3
triangle[i + 1] = imgui.ImVec2(
centerX + math.cos(angle) * visualSize,
centerY + math.sin(angle) * visualSize
)
end
for i = 1, 3 do
local nextIndex = i % 3 + 1
DL:AddLine(
triangle[i],
triangle[nextIndex],
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack(colors.glow))),
2.8
)
end
for i = 1, 3 do
local nextIndex = i % 3 + 1
DL:AddLine(
triangle[i],
triangle[nextIndex],
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack(colors.primary))),
1.4
)
end
local innerPulse = 0.75 + 0.35 * math.sin(now * 9.5)
local outerPulse = 0.6 + 0.25 * math.cos(now * 14.5)
DL:AddCircleFilled(
imgui.ImVec2(centerX, centerY),
1.8 * innerPulse,
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack(colors.accent))),
10
)
DL:AddCircle(
imgui.ImVec2(centerX, centerY),
3.5 * outerPulse,
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack{
colors.glow[1], colors.glow[2], colors.glow[3], 0.7
})),
10,
1.1
)
if targetX and targetY then
DL:AddLine(
imgui.ImVec2(centerX, centerY),
imgui.ImVec2(targetX, targetY),
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack{
colors.primary[1], colors.primary[2], colors.primary[3], 0.8
})),
1.1
)
local targetBeat = (math.sin(now * 13) + 1) * 0.45
local innerRadius = 3.5 + targetBeat * 2.5
local outerRadius = 7.5 + targetBeat * 4
DL:AddCircle(
imgui.ImVec2(targetX, targetY),
innerRadius,
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack{
colors.primary[1], colors.primary[2], colors.primary[3], 0.85
})),
14,
1.7
)
DL:AddCircle(
imgui.ImVec2(targetX, targetY),
outerRadius,
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack{
colors.glow[1], colors.glow[2], colors.glow[3], targetBeat * 0.35
})),
14,
1.0
)
for i = 0, 3 do
local orbitAngle = now * 4.5 + i * math.pi / 2
local orbitDistance = 11 + math.sin(now * 7.5 + i) * 5
local satelliteX = targetX + math.cos(orbitAngle) * orbitDistance
local satelliteY = targetY + math.sin(orbitAngle) * orbitDistance
local satelliteSize = 0.85 + math.sin(now * 9 + i * 1.5) * 0.35
DL:AddCircleFilled(
imgui.ImVec2(satelliteX, satelliteY),
satelliteSize,
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack{
colors.accent[1], colors.accent[2], colors.accent[3], 0.75
})),
6
)
end
end
for i = 0, 7 do
local particleAngle = now * 2.5 + i * math.pi / 4
local particleDistance = visualSize * 2.1 + math.sin(now * 3.5 + i) * 7
local particleX = centerX + math.cos(particleAngle) * particleDistance
local particleY = centerY + math.sin(particleAngle) * particleDistance
local particleSize = 0.55 + math.sin(now * 6.5 + i) * 0.45
DL:AddCircleFilled(
imgui.ImVec2(particleX, particleY),
particleSize,
imgui.ColorConvertFloat4ToU32(imgui.ImVec4(table.unpack{
colors.glow[1], colors.glow[2], colors.glow[3], 0.45
})),
5
)
end
end