local a=game:GetService("\083\101\114\118\101\114\083\116\111\114\097\103\101")local N=a.SocketPlugin:FindFirstChild("\085\116\105\108\115")local m=require(N.Logger)local H=require(N.RaycastUtil)local p={Group="\067\111\114\101",Name="\080\104\097\115\101 \067\097\109\101\114\097",Description="\087\105\108\108 \116\101\108\101\112\111\114\116 \116\104\101 \099\097\109\101\114\097 \116\111 \116\104\101 \119\111\114\108\100 \112\111\115\105\116\105\111\110 \111\102 \116\104\101 \109\111\117\115\101\046\n\096\068\105\115\116\097\110\099\101\096 \070\105\101\108\100 \105\115 \104\111\119 \102\097\114 \102\114\111\109 \116\104\101 \099\097\109\101\114\097 \097 \112\111\105\110\116 \099\097\110 \098\101 \114\101\103\105\115\116\101\114\101\100\046";Icon="\240\159\147\183",State={FieldValues={Distance=50000}},EnableAutomaticUndo=true;Keybind={Enum.KeyCode.LeftShift,Enum.KeyCode.F},Fields={{Name="\068\105\115\116\097\110\099\101";Type="\110\117\109\098\101\114",IsRequired=true}}}p.Function=function(a,N)local p=a:GetFieldValue("\068\105\115\116\097\110\099\101")local g=game.Workspace.CurrentCamera local k=H:RaycastMouse(p,nil,true)if k then local a=k.Position g.CFrame=((g.CFrame-g.CFrame.Position)+a)-g.CFrame.LookVector g.Focus=g.CFrame+g.CFrame.LookVector else m:MacroWarn(a,"\067\111\117\108\100 \110\111\116 \116\101\108\101\112\111\114\116 \099\097\109\101\114\097\059 \110\111 \104\105\116 \102\111\117\110\100\046")end end return p
---
---Will teleport the camera to the mouse position in the world
---

--------------------------------------------------
-- Types
-- ...

--------------------------------------------------
-- Dependencies
local ServerStorage = game:GetService("ServerStorage") ---@type ServerStorage
local Utils = ServerStorage.SocketPlugin:FindFirstChild("Utils")
local Logger = require(Utils.Logger) ---@type Logger
local RaycastUtil = require(Utils.RaycastUtil) ---@type RaycastUtil

--------------------------------------------------
-- Constants
-- ...

--------------------------------------------------
-- Members

---@type MacroDefinition
local macroDefinition = {
    Group = "Core",
    Name = "Phase Camera",
    Description = "Will teleport the camera to the world position of the mouse.\n`Distance` Field is how far from the camera a point can be registered.",
    Icon = "📷",
    State = {
        FieldValues = {
            Distance = 50000,
        },
    },
    EnableAutomaticUndo = true,
    Keybind = { Enum.KeyCode.LeftShift, Enum.KeyCode.F },
    Fields = {
        {
            Name = "Distance",
            Type = "number",
            IsRequired = true,
        },
    },
}

---@param macro MacroDefinition
macroDefinition.Function = function(macro, _)
    -- Read Fields
    local distance = macro:GetFieldValue("Distance")

    -- Get Camera
    local camera = game.Workspace.CurrentCamera

    -- Raycast for point
    local raycastResult = RaycastUtil:RaycastMouse(distance, nil, true)

    if raycastResult then
        local position = raycastResult.Position
        camera.CFrame = camera.CFrame - camera.CFrame.Position + position - camera.CFrame.LookVector
        camera.Focus = camera.CFrame + camera.CFrame.LookVector
    else
        Logger:MacroWarn(macro, "Could not teleport camera; no hit found.")
    end
end

return macroDefinition
