-- Unsafe to use with non-Portalshot modes.

function CircularEdge.new(Activity)
    local self = {
        Generator = Random.new(os.time());
        Activity = Activity;
    }

    return setmetatable(self, CircularEdge)
end

function CircularEdge:GetRotation(N: number): number
    -- We do this to include the noiseness factor.
    return self.Generator:NextInteger(-N, N) + self.Generator:NextNumber()
end

function CircularEdge:GetNextPoint(Player: Player): CFrame
    local Origin: CFrame = self.Activity.SpawnArea:GetTargetAreaPosition(Player)
    local TargetAreaSize = self.Activity.Settings.TargetAreaSize

    return Origin
        * CFrame.Angles(0, math.rad(self:GetRotation(self.Activity.SpawnMechanism.State.Angles / 2)), 0)
        * CFrame.Angles(math.rad(self:GetRotation(TargetAreaSize.Y / 2)), 0, 0)
        * CFrame.new(TargetAreaSize.X / 2, 0, TargetAreaSize.Z / 2)
end

CircularEdge.GetStartingPoint = CircularEdge.GetNextPoint

return CircularEdge
